[PATCH] Cmm: don't perform unsound optimizations on 32-bit compiler hosts
authorSylvain Henry <sylvain@haskus.fr>
Thu, 1 Aug 2024 13:59:14 +0000 (15:59 +0200)
committerIlias Tsitsimpis <iliastsi@debian.org>
Sun, 15 Sep 2024 21:17:25 +0000 (00:17 +0300)
commit4ba62032f800bad259a8ebfb2458cfd8cf561fee
tree513874c32a4f29c286a70fa56fae4c0677441d25
parent00142562f1e72318290eb82d20d43f01420296ed
[PATCH] Cmm: don't perform unsound optimizations on 32-bit compiler hosts

beef61351b240967b49169d27a9a19565cf3c4af enabled the use of
  MO_Add/MO_Sub for 64-bit operations in the C and LLVM backends
6755d833af8c21bbad6585144b10e20ac4a0a1ab 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 and #24700).

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 <amesgen@amesgen.de>
Gbp-Pq: Name pr-13096
compiler/GHC/Cmm/Opt.hs