[Git][ghc/ghc][master] Bignum: add integerNegate RULE

Marge Bot gitlab at gitlab.haskell.org
Thu Oct 1 22:38:42 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00
Bignum: add integerNegate RULE

- - - - -


4 changed files:

- libraries/ghc-bignum/src/GHC/Num/Integer.hs
- testsuite/tests/lib/integer/all.T
- + testsuite/tests/lib/integer/integerNegate.hs
- + testsuite/tests/lib/integer/integerNegate.stderr


Changes:

=====================================
libraries/ghc-bignum/src/GHC/Num/Integer.hs
=====================================
@@ -486,6 +486,9 @@ integerNegate (IP b)
   | isTrue# (bigNatEqWord# b ABS_INT_MINBOUND##) = IS INT_MINBOUND#
   | True                                         = IN b
 
+{-# RULES
+"integerNegate/integerNegate" forall x. integerNegate (integerNegate x) = x
+#-}
 
 -- | Compute absolute value of an 'Integer'
 integerAbs :: Integer -> Integer


=====================================
testsuite/tests/lib/integer/all.T
=====================================
@@ -1,3 +1,4 @@
+test('integerNegate', normal, compile, ['-ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
 test('integerBits', normal, compile_and_run, [''])
 test('integerConversions', normal, compile_and_run, [''])
 test('plusMinusInteger', [omit_ways(['ghci'])], compile_and_run, [''])


=====================================
testsuite/tests/lib/integer/integerNegate.hs
=====================================
@@ -0,0 +1,8 @@
+{-# OPTIONS_GHC -O2 #-}
+
+module Test where
+
+import GHC.Num.Integer
+
+neg_neg :: Integer -> Integer
+neg_neg x = integerNegate (integerNegate x)


=====================================
testsuite/tests/lib/integer/integerNegate.stderr
=====================================
@@ -0,0 +1,10 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+  = {terms: 3, types: 3, coercions: 0, joins: 0/0}
+
+-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0}
+neg_neg = \ x -> x
+
+
+



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5523324d2c55e0091857e21bf5613b5f6b442a7

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5523324d2c55e0091857e21bf5613b5f6b442a7
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201001/6a4e8eb7/attachment-0001.html>


More information about the ghc-commits mailing list