diff options
author | Takano Akio <tak@anoak.io> | 2016-09-04 13:22:22 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-09-05 14:58:20 -0400 |
commit | 6ea62427de419ea071e1ea79ad0c15d9f4e90a67 (patch) | |
tree | 370423005b992268abf3b401d445bb48efed39bf /testsuite/tests | |
parent | 71dd6e4429833238bcdaf96da8e2e41a62dacbf4 (diff) | |
download | haskell-6ea62427de419ea071e1ea79ad0c15d9f4e90a67.tar.gz |
Turn divInt# and modInt# into bitwise operations when possible
This implements #5615 for divInt# and modInt#.
I also included rules to do constant-folding when the both arguments
are known.
Test Plan: validate
Reviewers: austin, simonmar, bgamari
Reviewed By: bgamari
Subscribers: hvr, thomie
Differential Revision: https://phabricator.haskell.org/D2486
GHC Trac Issues: #5615
Diffstat (limited to 'testsuite/tests')
4 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/Makefile b/testsuite/tests/simplCore/should_compile/Makefile index 8b7da66e27..288e3f96e5 100644 --- a/testsuite/tests/simplCore/should_compile/Makefile +++ b/testsuite/tests/simplCore/should_compile/Makefile @@ -144,3 +144,13 @@ T10083: '$(TEST_HC)' $(TEST_HC_OPTS) -c -O T10083.hs-boot '$(TEST_HC)' $(TEST_HC_OPTS) -c -O T10083a.hs '$(TEST_HC)' $(TEST_HC_OPTS) -c -O T10083.hs + +.PHONY: T5615 +T5615: + $(RM) -f T5615.o T5615.hi T5615.dump-simpl + '$(TEST_HC)' $(TEST_HC_OPTS) -c -O T5615.hs -ddump-simpl -ddump-to-file + -grep 'divInt#' T5615.dump-simpl + -grep 'modInt#' T5615.dump-simpl + -grep 'quotInt#' T5615.dump-simpl + -grep 'remInt#' T5615.dump-simpl + grep -c '1999#' T5615.dump-simpl diff --git a/testsuite/tests/simplCore/should_compile/T5615.hs b/testsuite/tests/simplCore/should_compile/T5615.hs new file mode 100644 index 0000000000..984480431b --- /dev/null +++ b/testsuite/tests/simplCore/should_compile/T5615.hs @@ -0,0 +1,10 @@ +main :: IO () +main = do + printInt $ 9999 `div` 5 + printInt $ 9999 `mod` 5 + n <- readLn + printInt $ n `div` 4 + printInt $ n `mod` 4 + +printInt :: Int -> IO () +printInt = print diff --git a/testsuite/tests/simplCore/should_compile/T5615.stdout b/testsuite/tests/simplCore/should_compile/T5615.stdout new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/testsuite/tests/simplCore/should_compile/T5615.stdout @@ -0,0 +1 @@ +1 diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T index e2e0bb6c31..f985b4a859 100644 --- a/testsuite/tests/simplCore/should_compile/all.T +++ b/testsuite/tests/simplCore/should_compile/all.T @@ -137,6 +137,7 @@ test('simpl021', run_command, ['$MAKE -s --no-print-directory simpl021']) test('T5327', normal, run_command, ['$MAKE -s --no-print-directory T5327']) +test('T5615', normal, run_command, ['$MAKE -s --no-print-directory T5615']) test('T5623', normal, run_command, ['$MAKE -s --no-print-directory T5623']) test('T5658b', normal, |