diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2023-01-27 15:07:26 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-04-13 08:50:33 -0400 |
commit | 8af401ccfbe28d7bbfc493c0097834e9c66a36b0 (patch) | |
tree | bed049f72ef9c113812247ba2647b08681079d4f | |
parent | 1148ac723d6a879593dc4e7941a49b8e74e4c7d7 (diff) | |
download | haskell-8af401ccfbe28d7bbfc493c0097834e9c66a36b0.tar.gz |
Make WordQuotRem2Op ok-for-speculation too
-rw-r--r-- | compiler/GHC/Builtin/PrimOps.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Core/Utils.hs | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/compiler/GHC/Builtin/PrimOps.hs b/compiler/GHC/Builtin/PrimOps.hs index a6faaa09b1..82a35423f0 100644 --- a/compiler/GHC/Builtin/PrimOps.hs +++ b/compiler/GHC/Builtin/PrimOps.hs @@ -551,7 +551,6 @@ primOpIsCheap op = primOpOkForSpeculation op primOpIsDiv :: PrimOp -> Bool primOpIsDiv op = case op of - -- TODO: quotRemWord2 IntQuotOp -> True Int8QuotOp -> True Int16QuotOp -> True @@ -588,6 +587,8 @@ primOpIsDiv op = case op of Word32QuotRemOp -> True -- Word64QuotRemOp doesn't exist (yet) + WordQuotRem2Op -> True + FloatDivOp -> True DoubleDivOp -> True _ -> False diff --git a/compiler/GHC/Core/Utils.hs b/compiler/GHC/Core/Utils.hs index 21ceb2a7bb..565bf698bc 100644 --- a/compiler/GHC/Core/Utils.hs +++ b/compiler/GHC/Core/Utils.hs @@ -1615,8 +1615,10 @@ app_ok fun_ok primop_ok fun args PrimOpId op _ | primOpIsDiv op - , [arg1, Lit lit] <- args - -> not (isZeroLit lit) && expr_ok fun_ok primop_ok arg1 + , Lit divisor <- last args + -- there can be 2 args (most div primops) or 3 args + -- (WordQuotRem2Op), hence the use of last/init + -> not (isZeroLit divisor) && all (expr_ok fun_ok primop_ok) (init args) -- Special case for dividing operations that fail -- In general they are NOT ok-for-speculation -- (which primop_ok will catch), but they ARE OK |