PowerPC Big-Endian: ArithInt16, ArithInt8, ArithWord16, and ArithWord8 fail
The tests were run on a PowerMac G5 running Linux, PowerMacs are big-endian.
I reduced the issue to this program where I get the incorrect answer 25132
:
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
module Main where
import GHC.Exts
main :: IO ()
main = do
putStrLn $ show (apply2 plusInt16# (50) (50))
apply2 :: (Int16# -> Int16# -> Int16#) -> Int -> Int -> Int
apply2 op (I# a) (I# b) =
let (# sa, sb #) = (# narrowInt16# a, narrowInt16# b #)
r = op sa sb
in I# (extendInt16# r)
{-# NOINLINE apply2 #-}
Curiously, when I inline plusInt16#
and remove the op parameter the result is correct.
The test passes on little-endian PowerPC 64-bit.
Note: This bug is different from #16222 (closed), which deals with the C calling convention.