diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-05-04 15:10:04 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-05 14:35:17 -0400 |
commit | 11240b7427c54c3233aa3cce5adc3a5209df8031 (patch) | |
tree | b6d5198009cb222c3a720efbc918c9489372840d /testsuite/tests/numeric | |
parent | 52400ebb537504eb0f8e0f4678f3f721b2fbc2d9 (diff) | |
download | haskell-11240b7427c54c3233aa3cce5adc3a5209df8031.tar.gz |
Constant folding for (.&.) maxBound (#20448)
Diffstat (limited to 'testsuite/tests/numeric')
-rw-r--r-- | testsuite/tests/numeric/should_compile/T20448.hs | 36 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/T20448.stderr | 27 | ||||
-rw-r--r-- | testsuite/tests/numeric/should_compile/all.T | 1 |
3 files changed, 64 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_compile/T20448.hs b/testsuite/tests/numeric/should_compile/T20448.hs new file mode 100644 index 0000000000..1f98a3a826 --- /dev/null +++ b/testsuite/tests/numeric/should_compile/T20448.hs @@ -0,0 +1,36 @@ +module Test where + +import Data.Word +import Data.Int +import Data.Bits + +w8 :: Word8 -> Word8 +w8 x = x .&. 0xFF + +w16 :: Word16 -> Word16 +w16 x = x .&. 0xFFFF + +w32 :: Word32 -> Word32 +w32 x = x .&. 0xFFFFFFFF + +w64 :: Word64 -> Word64 +w64 x = x .&. 0xFFFFFFFFFFFFFFFF + +w :: Word -> Word +w x = x .&. maxBound + + +i8 :: Int8 -> Int8 +i8 x = x .&. (-1) + +i16 :: Int16 -> Int16 +i16 x = x .&. (-1) + +i32 :: Int32 -> Int32 +i32 x = x .&. (-1) + +i64 :: Int64 -> Int64 +i64 x = x .&. (-1) + +i :: Int -> Int +i x = x .&. (-1) diff --git a/testsuite/tests/numeric/should_compile/T20448.stderr b/testsuite/tests/numeric/should_compile/T20448.stderr new file mode 100644 index 0000000000..5cbea14d1f --- /dev/null +++ b/testsuite/tests/numeric/should_compile/T20448.stderr @@ -0,0 +1,27 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 30, types: 30, coercions: 0, joins: 0/0} + +w8 = \ x -> x + +w16 = \ x -> x + +w32 = \ x -> x + +w64 = \ x -> x + +w = \ x -> x + +i8 = \ x -> x + +i16 = \ x -> x + +i32 = \ x -> x + +i64 = \ x -> x + +i = \ x -> x + + + diff --git a/testsuite/tests/numeric/should_compile/all.T b/testsuite/tests/numeric/should_compile/all.T index 59b66f8d5f..087eb7b358 100644 --- a/testsuite/tests/numeric/should_compile/all.T +++ b/testsuite/tests/numeric/should_compile/all.T @@ -16,3 +16,4 @@ test('T20376', normal, compile, ['-ddump-simpl -O -dsuppress-all -dsuppress-uniq test('T20374', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques']) test('T19769', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques']) test('T20347', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques']) +test('T20448', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques']) |