[commit: ghc] ghc-8.0: PrelRules: Fix constant folding for WordRemOp (630d079)

git at git.haskell.org git at git.haskell.org
Wed Mar 23 16:37:47 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/630d07995a814f665531eaecf07dffe1298c6fd5/ghc

>---------------------------------------------------------------

commit 630d07995a814f665531eaecf07dffe1298c6fd5
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Wed Mar 16 10:00:12 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
    
    (cherry picked from commit 3ddfcc95cd41dac19c8f4d55e8fc03128b77b738
     and commit c095ec5d970ec3a3a00a1920c01f67df52d07060)


>---------------------------------------------------------------

630d07995a814f665531eaecf07dffe1298c6fd5
 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 440b3c1..4df3418 100644
--- a/compiler/prelude/PrelRules.hs
+++ b/compiler/prelude/PrelRules.hs
@@ -138,7 +138,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 050de91..d6b7197 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/tests/numeric/should_run/all.T
@@ -65,4 +65,4 @@ test('CarryOverflow', omit_ways(['ghci']), 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', extra_ways(['optasm']), compile_and_run, [''])



More information about the ghc-commits mailing list