summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2023-01-27 15:07:26 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-04-13 08:50:33 -0400
commit8af401ccfbe28d7bbfc493c0097834e9c66a36b0 (patch)
treebed049f72ef9c113812247ba2647b08681079d4f /compiler/GHC/Core
parent1148ac723d6a879593dc4e7941a49b8e74e4c7d7 (diff)
downloadhaskell-8af401ccfbe28d7bbfc493c0097834e9c66a36b0.tar.gz
Make WordQuotRem2Op ok-for-speculation too
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r--compiler/GHC/Core/Utils.hs6
1 files changed, 4 insertions, 2 deletions
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