diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2023-01-27 14:10:50 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-04-13 08:50:33 -0400 |
commit | 1148ac723d6a879593dc4e7941a49b8e74e4c7d7 (patch) | |
tree | 2af3c25e75c9fd22e1e754ce260e917b742f11dc | |
parent | 4dd021227559e1bc70cdaed12e45ff5459c33d27 (diff) | |
download | haskell-1148ac723d6a879593dc4e7941a49b8e74e4c7d7.tar.gz |
Make Int64/Word64 division ok for speculation too.
Only when the divisor is definitely non-zero.
-rw-r--r-- | compiler/GHC/Builtin/PrimOps.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/primops/should_compile/T22152b.stderr | 15 |
2 files changed, 10 insertions, 13 deletions
diff --git a/compiler/GHC/Builtin/PrimOps.hs b/compiler/GHC/Builtin/PrimOps.hs index c9f0d56aaf..a6faaa09b1 100644 --- a/compiler/GHC/Builtin/PrimOps.hs +++ b/compiler/GHC/Builtin/PrimOps.hs @@ -551,36 +551,42 @@ primOpIsCheap op = primOpOkForSpeculation op primOpIsDiv :: PrimOp -> Bool primOpIsDiv op = case op of - -- TODO: quotRemWord2, Int64, Word64 + -- TODO: quotRemWord2 IntQuotOp -> True Int8QuotOp -> True Int16QuotOp -> True Int32QuotOp -> True + Int64QuotOp -> True IntRemOp -> True Int8RemOp -> True Int16RemOp -> True Int32RemOp -> True + Int64RemOp -> True IntQuotRemOp -> True Int8QuotRemOp -> True Int16QuotRemOp -> True Int32QuotRemOp -> True + -- Int64QuotRemOp doesn't exist (yet) WordQuotOp -> True Word8QuotOp -> True Word16QuotOp -> True Word32QuotOp -> True + Word64QuotOp -> True WordRemOp -> True Word8RemOp -> True Word16RemOp -> True Word32RemOp -> True + Word64RemOp -> True WordQuotRemOp -> True Word8QuotRemOp -> True Word16QuotRemOp -> True Word32QuotRemOp -> True + -- Word64QuotRemOp doesn't exist (yet) FloatDivOp -> True DoubleDivOp -> True diff --git a/testsuite/tests/primops/should_compile/T22152b.stderr b/testsuite/tests/primops/should_compile/T22152b.stderr index 0cf317cc32..69a2cfbc82 100644 --- a/testsuite/tests/primops/should_compile/T22152b.stderr +++ b/testsuite/tests/primops/should_compile/T22152b.stderr @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 119, types: 59, coercions: 0, joins: 0/0} + = {terms: 103, types: 55, coercions: 0, joins: 0/0} b = \ x -> case x of { I# x1 -> I# (quotInt# x1 200#) } @@ -16,11 +16,7 @@ f = \ x -> case x of { W32# x# -> W32# (quotWord32# x# 200#Word32) } g = \ x -> - case x of { W64# x# -> - case quotWord64# x# 10#Word64 of ds1 { __DEFAULT -> - case quotWord64# ds1 20#Word64 of ds2 { __DEFAULT -> W64# ds2 } - } - } + case x of { W64# x# -> W64# (quotWord64# x# 200#Word64) } h = \ x -> case x of { I8# x# -> @@ -36,12 +32,7 @@ a = \ x -> I32# (quotInt32# (quotInt32# x# 2147483647#Int32) 2147483647#Int32) } -k = \ x -> - case x of { I64# x# -> - case quotInt64# x# 10#Int64 of ds { __DEFAULT -> - case quotInt64# ds 20#Int64 of ds1 { __DEFAULT -> I64# ds1 } - } - } +k = \ x -> case x of { I64# x# -> I64# (quotInt64# x# 200#Int64) } |