diff options
Diffstat (limited to 'compiler')
-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 |