summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <astrohavoc@gmail.com>2022-03-08 09:29:14 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-03-11 20:00:01 -0500
commit6bdcd5573a1fe67dd872c55e5911a1186071c5d3 (patch)
treedb7ded3bf91ec35ace7785d4199f2b066216d6d1
parent524795feabf3a977d074f40b482ed7d8893f8710 (diff)
downloadhaskell-6bdcd5573a1fe67dd872c55e5911a1186071c5d3.tar.gz
CmmToC: make 64-bit word splitting for 32-bit targets respect target endianness
This used to been broken for little-endian targets.
-rw-r--r--compiler/GHC/CmmToC.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/GHC/CmmToC.hs b/compiler/GHC/CmmToC.hs
index 60059124b2..30568b0995 100644
--- a/compiler/GHC/CmmToC.hs
+++ b/compiler/GHC/CmmToC.hs
@@ -645,7 +645,9 @@ staticLitsToWords platform = go . foldMap decomposeMultiWord
= [floatToWord32 n]
decomposeMultiWord (CmmInt n W64)
| W32 <- wordWidth platform
- = [CmmInt hi W32, CmmInt lo W32]
+ = case platformByteOrder platform of
+ BigEndian -> [CmmInt hi W32, CmmInt lo W32]
+ LittleEndian -> [CmmInt lo W32, CmmInt hi W32]
where
hi = n `shiftR` 32
lo = n .&. 0xffffffff