[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>
Mon, 17 Feb 2025 08:44:23 +0000 (09:44 +0100)
commit89486b6ec4d20d8af81e0d23bc2e1a1320719c3f
tree159b1fea0a13946a2f95dc3a78882c2de71efac1
parentc4fd562afc9521bc87ffabaddafa8062901d19ad
[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