{-# LANGUAGE MagicHash #-} import GHC.Exts import Data.Word import Data.Int (+&) = plusWord# (-&) = minusWord# (*&) = timesWord# {-# NOINLINE testsW #-} -- NOINLINE otherwise basic constant folding rules (without -- variables) are applied testsW :: Word# -> Word# -> [Word] testsW x y = fmap (\z -> fromIntegral (fromIntegral z :: Word32)) -- narrowing to get the same results on both 64- and 32-bit arch [ W# (43## +& (37## +& x)) , W# (43## +& (37## -& x)) , W# (43## +& (x -& 37##)) , W# (43## -& (37## +& x)) , W# (43## -& (37## -& x)) , W# (43## -& (x -& 37##)) , W# ((43## +& x) -& 37##) , W# ((x +& 43##) -& 37##) , W# ((43## -& x) -& 37##) , W# ((x -& 43##) -& 37##) , W# ((x +& 43##) +& (y +& 37##)) , W# ((x +& 43##) +& (y -& 37##)) , W# ((x +& 43##) +& (37## -& y)) , W# ((x -& 43##) +& (37## -& y)) , W# ((x -& 43##) +& (y -& 37##)) , W# ((43## -& x) +& (37## -& y)) , W# ((43## -& x) +& (y -& 37##)) ] {-# NOINLINE testsI #-} testsI :: Int# -> Int# -> [Int] testsI x y = fmap (\z -> fromIntegral (fromIntegral z :: Int32)) [ I# (43# +# (37# +# x)) , I# (43# +# (37# -# x)) , I# (43# +# (x -# 37#)) , I# (43# -# (37# +# x)) , I# (43# -# (37# -# x)) , I# (43# -# (x -# 37#)) , I# ((43# +# x) -# 37#) , I# ((x +# 43#) -# 37#) , I# ((43# -# x) -# 37#) , I# ((x -# 43#) -# 37#) , I# ((x +# 43#) +# (y +# 37#)) , I# ((x +# 43#) +# (y -# 37#)) , I# ((x +# 43#) +# (37# -# y)) , I# ((x -# 43#) +# (37# -# y)) , I# ((x -# 43#) +# (y -# 37#)) , I# ((43# -# x) +# (37# -# y)) , I# ((43# -# x) +# (y -# 37#)) , I# ((x +# 43#) -# (y +# 37#)) , I# ((x +# 43#) -# (y -# 37#)) , I# ((x +# 43#) -# (37# -# y)) , I# ((x -# 43#) -# (y +# 37#)) , I# ((43# -# x) -# (37# +# y)) , I# ((x -# 43#) -# (y -# 37#)) , I# ((x -# 43#) -# (37# -# y)) , I# ((43# -# x) -# (y -# 37#)) , I# ((43# -# x) -# (37# -# y)) , I# (43# *# (37# *# y)) , I# (43# *# (y *# 37#)) , I# ((43# *# x) *# (y *# 37#)) , I# (43# *# (37# +# y)) , I# (43# *# (37# -# y)) , I# (43# *# (y -# 37#)) , I# (x +# x) , I# ((43# *# x) +# x) , I# (x +# (43# *# x)) , I# ((43# *# x) +# (37# *# x)) , I# ((43# *# x) +# (x *# 37#)) , I# (x -# x) , I# ((43# *# x) -# x) , I# (x -# (43# *# x)) , I# ((43# *# x) -# (37# *# x)) , I# ((43# *# x) -# (x *# 37#)) , I# (x +# (37# +# y)) , I# (x +# (y +# 37#)) , I# (x +# (37# -# y)) , I# (x +# (y -# 37#)) , I# (x -# (37# +# y)) , I# (x -# (y +# 37#)) , I# (x -# (37# -# y)) , I# (x -# (y -# 37#)) , I# ((37# +# y) -# x) , I# ((y +# 37#) -# x) , I# ((37# -# y) -# x) , I# ((y -# 37#) -# x) , I# (y *# y) ] main :: IO () main = do print (testsW 7## 13##) print (testsI 7# 13#)