[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)
committerGianfranco Costamagna <locutusofborg@debian.org>
Tue, 5 Nov 2024 23:21:23 +0000 (00:21 +0100)
commitd67cd3ce1d5be5155e936722fe1adda83744a043
tree6a02de33283cbf7859a7f39d60d2308603db7d59
parent0f8ac307e77ffc2301427e3641879f32ff8d25d6
[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