Cmm: don't perform unsound optimizations on 32-bit compiler hosts (#24893 #24700)

  • beef6135 enabled the use of MO_Add/MO_Sub for 64-bit operations in the C and LLVM backends
  • 6755d833 did the same for the x86 NCG backend

However we store some literal values as Int in the compiler. As a result, some Cmm optimizations transformed target 64-bit literals into compiler Int. If the compiler is 32-bit, this leads to computing with wrong literals (see #24893 (closed) and #24700 (closed)).

This patch disables these Cmm optimizations for 32-bit compilers. This is unsatisfying (optimizations shouldn't be compiler-word-size dependent) but it fixes the bug and it makes the patch easy to backport. A proper fix would be much more invasive but it shall be implemented in the future.

Co-authored by @amesgen


After 3 attempts to refactor the backends to use Integer (or Int64) instead of Int in a few places, I came to the same conclusion as @amesgen in !12756 (comment 576956): let's first fix the bug with a patch easy to backport. I'll refactor the backends in HEAD for some future release.

Merge request reports

Loading