Skip to content

x86: Improved handling of -CriotR cases for LEA optimisations and some min/max speed-ups

Summary

This merge request uses a more concrete and reusable system for adjusting address offsets, especially in LEA instructions, where there's a risk of them overflowing. The new functions, IncOffset and DecOffset, will return False if an overflow occurs and won't cause range check errors when the compiler is built under -CriotR rules.

Additionally, two pairs of new min and max functions that work with SmallInt and Word types have been introduced into the compiler. This is primarily to benefit i8086 targets in the new offset adjustment functions, which are restricted to signed 16-bit integers, but also show benefit elsewhere in the compiler.

System

  • Processor architecture: i8086, i386, x86_64

What is the current bug behavior?

N/A

What is the behavior after applying this patch?

Some compiler code is improved thanks to the new min and max functions that work with smaller types, although RTL code shouldn't notably change unless it was buggy before. Also, -CriotR should be successful.

Additional Notes

Due to #39433, some constants have to be explicitly typecast so an incorrect compiler error doesn't occur. These typecasts can be removed once the bug is fixed in the bootstrapping compiler (the bug is present from 3.2.0 to trunk).

Merge request reports