diff options
-rw-r--r-- | compiler/GHC/Cmm/Opt.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/cmm/opt/T18141.hs | 17 | ||||
-rw-r--r-- | testsuite/tests/cmm/opt/all.T | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/compiler/GHC/Cmm/Opt.hs b/compiler/GHC/Cmm/Opt.hs index 4ac24523c1..493122024c 100644 --- a/compiler/GHC/Cmm/Opt.hs +++ b/compiler/GHC/Cmm/Opt.hs @@ -69,6 +69,7 @@ cmmMachOpFoldM _ op [CmmLit (CmmInt x rep)] MO_SF_Conv _from to -> CmmLit (CmmFloat (fromInteger x) to) MO_SS_Conv from to -> CmmLit (CmmInt (narrowS from x) to) MO_UU_Conv from to -> CmmLit (CmmInt (narrowU from x) to) + MO_XX_Conv from to -> CmmLit (CmmInt (narrowS from x) to) _ -> panic $ "cmmMachOpFoldM: unknown unary op: " ++ show op @@ -76,6 +77,7 @@ cmmMachOpFoldM _ op [CmmLit (CmmInt x rep)] -- Eliminate conversion NOPs cmmMachOpFoldM _ (MO_SS_Conv rep1 rep2) [x] | rep1 == rep2 = Just x cmmMachOpFoldM _ (MO_UU_Conv rep1 rep2) [x] | rep1 == rep2 = Just x +cmmMachOpFoldM _ (MO_XX_Conv rep1 rep2) [x] | rep1 == rep2 = Just x -- Eliminate nested conversions where possible cmmMachOpFoldM platform conv_outer [CmmMachOp conv_inner [x]] diff --git a/testsuite/tests/cmm/opt/T18141.hs b/testsuite/tests/cmm/opt/T18141.hs new file mode 100644 index 0000000000..9f2c2a79c7 --- /dev/null +++ b/testsuite/tests/cmm/opt/T18141.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE MagicHash #-} + +module T18141 where + +import GHC.Exts + +divInt8# :: Int8# -> Int8# -> Int8# +x# `divInt8#` y# + | isTrue# (x# `gtInt8#` zero#) && isTrue# (y# `ltInt8#` zero#) = + ((x# `subInt8#` one#) `quotInt8#` y#) `subInt8#` one# + | isTrue# (x# `ltInt8#` zero#) && isTrue# (y# `gtInt8#` zero#) = + ((x# `plusInt8#` one#) `quotInt8#` y#) `subInt8#` one# + | otherwise = x# `quotInt8#` y# + where + zero# = narrowInt8# 0# + one# = narrowInt8# 1# + diff --git a/testsuite/tests/cmm/opt/all.T b/testsuite/tests/cmm/opt/all.T index 24572a219b..da7e95d5c4 100644 --- a/testsuite/tests/cmm/opt/all.T +++ b/testsuite/tests/cmm/opt/all.T @@ -1,3 +1,4 @@ # Verify that we optimize away conditional branches which always jump # to the same target. test('T15188', normal, makefile_test, []) +test('T18141', normal, compile, ['']) |