Commit e5523324 authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot
Browse files

Bignum: add integerNegate RULE

parent a8018c17
...@@ -486,6 +486,9 @@ integerNegate (IP b) ...@@ -486,6 +486,9 @@ integerNegate (IP b)
| isTrue# (bigNatEqWord# b ABS_INT_MINBOUND##) = IS INT_MINBOUND# | isTrue# (bigNatEqWord# b ABS_INT_MINBOUND##) = IS INT_MINBOUND#
| True = IN b | True = IN b
{-# RULES
"integerNegate/integerNegate" forall x. integerNegate (integerNegate x) = x
#-}
-- | Compute absolute value of an 'Integer' -- | Compute absolute value of an 'Integer'
integerAbs :: Integer -> Integer integerAbs :: Integer -> Integer
......
test('integerNegate', normal, compile, ['-ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
test('integerBits', normal, compile_and_run, ['']) test('integerBits', normal, compile_and_run, [''])
test('integerConversions', normal, compile_and_run, ['']) test('integerConversions', normal, compile_and_run, [''])
test('plusMinusInteger', [omit_ways(['ghci'])], compile_and_run, ['']) test('plusMinusInteger', [omit_ways(['ghci'])], compile_and_run, [''])
......
{-# OPTIONS_GHC -O2 #-}
module Test where
import GHC.Num.Integer
neg_neg :: Integer -> Integer
neg_neg x = integerNegate (integerNegate x)
==================== 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment