summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Utils.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2023-01-27 15:07:26 +0100
committerSylvain Henry <sylvain@haskus.fr>2023-03-30 15:33:30 +0200
commit17822d93cd4f5c0cde6453779a8be4267a9cc5a2 (patch)
tree2dbb2f63bc8a40fa05f0303d3e738389795e90bb /compiler/GHC/Core/Utils.hs
parent29ae8fddaa0df13fca9f151e26c9fa0fe9abeb85 (diff)
downloadhaskell-wip/T22152.tar.gz
Make WordQuotRem2Op ok-for-speculation toowip/T22152
Diffstat (limited to 'compiler/GHC/Core/Utils.hs')
-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