[commit: ghc] master: PrelRules: Fix constant folding for WordRemOp (3ddfcc9)
git at git.haskell.org
git at git.haskell.org
Sun Mar 20 16:33:02 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/3ddfcc95cd41dac19c8f4d55e8fc03128b77b738/ghc
>---------------------------------------------------------------
commit 3ddfcc95cd41dac19c8f4d55e8fc03128b77b738
Author: Ben Gamari <bgamari.foss at gmail.com>
Date: Mon Mar 14 13:27:00 2016 +0100
PrelRules: Fix constant folding for WordRemOp
Test Plan: Validate with testcase in D2002
Reviewers: austin, simonpj
Reviewed By: simonpj
Subscribers: simonpj, thomie
Differential Revision: https://phabricator.haskell.org/D2004
GHC Trac Issues: #11702
>---------------------------------------------------------------
3ddfcc95cd41dac19c8f4d55e8fc03128b77b738
compiler/prelude/PrelRules.hs | 7 ++++++-
testsuite/tests/numeric/should_run/all.T | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/compiler/prelude/PrelRules.hs b/compiler/prelude/PrelRules.hs
index 314dd85..a57609a 100644
--- a/compiler/prelude/PrelRules.hs
+++ b/compiler/prelude/PrelRules.hs
@@ -134,7 +134,12 @@ primOpRules nm WordMulOp = mkPrimOpRule nm 2 [ binaryLit (wordOp2 (*))
primOpRules nm WordQuotOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 quot)
, rightIdentityDynFlags onew ]
primOpRules nm WordRemOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 rem)
- , rightIdentityDynFlags onew ]
+ , leftZero zerow
+ , do l <- getLiteral 1
+ dflags <- getDynFlags
+ guard (l == onew dflags)
+ retLit zerow
+ , equalArgs >> retLit zerow ]
primOpRules nm AndOp = mkPrimOpRule nm 2 [ binaryLit (wordOp2 (.&.))
, idempotent
, zeroElem zerow ]
diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T
index 515005f..8c80305 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/tests/numeric/should_run/all.T
@@ -66,4 +66,4 @@ test('T9407', normal, compile_and_run, [''])
test('T9810', normal, compile_and_run, [''])
test('T10011', normal, compile_and_run, [''])
test('T10962', omit_ways(['ghci']), compile_and_run, [''])
-test('T11702', expect_broken(11702), compile_and_run, [''])
+test('T11702', normal, compile_and_run, [''])
More information about the ghc-commits
mailing list