summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen
diff options
context:
space:
mode:
authorklebinger.andreas@gmx.at <klebinger.andreas@gmx.at>2018-09-18 17:46:38 +0200
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>2018-09-18 19:05:56 +0200
commit6bb9bc7d3c935dcb77e0700cce28de2c9df646df (patch)
tree04a5d2e6466e626b3b60f83e62ffae418463678b /testsuite/tests/codeGen
parentce3897ffd6e7c8b8f36b8e920168bac8c7f836ae (diff)
downloadhaskell-6bb9bc7d3c935dcb77e0700cce28de2c9df646df.tar.gz
Invert FP conditions to eliminate the explicit NaN check.
Summary: Optimisation: we don't have to test the parity flag if we know the test has already excluded the unordered case: eg > and >= test for a zero carry flag, which can only occur for ordered operands. By reversing comparisons we can avoid testing the parity for < and <= as well. This works since: * If any of the arguments is an NaN CF gets set. Resulting in a false result. * Since this allows us to rule out NaN we can exchange the arguments and invert the direction of the arrows. Test Plan: ci/nofib Reviewers: carter, bgamari, alpmestan Reviewed By: alpmestan Subscribers: alpmestan, simonpj, jmct, rwbarton, thomie GHC Trac Issues: #15196 Differential Revision: https://phabricator.haskell.org/D4990
Diffstat (limited to 'testsuite/tests/codeGen')
-rw-r--r--testsuite/tests/codeGen/should_compile/Makefile3
-rw-r--r--testsuite/tests/codeGen/should_compile/T15196.hs4
-rw-r--r--testsuite/tests/codeGen/should_compile/T15196.stdout1
-rw-r--r--testsuite/tests/codeGen/should_compile/all.T6
4 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_compile/Makefile b/testsuite/tests/codeGen/should_compile/Makefile
index 82896adbba..c94c8b6f92 100644
--- a/testsuite/tests/codeGen/should_compile/Makefile
+++ b/testsuite/tests/codeGen/should_compile/Makefile
@@ -38,3 +38,6 @@ T14999:
'$(TEST_HC)' $(TEST_HC_OPTS) -O2 -g -c T14999.cmm -o T14999.o
gdb --batch -ex 'file T14999.o' -ex 'disassemble stg_catch_frame_info' --nx | tr -s '[[:blank:]\n]'
readelf --debug-dump=frames-interp T14999.o | tr -s '[[:blank:]\n]'
+
+T15196:
+ '$(TEST_HC)' $(TEST_HC_OPTS) -c -O -ddump-asm T15196.hs | grep "jp " ; echo $$?
diff --git a/testsuite/tests/codeGen/should_compile/T15196.hs b/testsuite/tests/codeGen/should_compile/T15196.hs
new file mode 100644
index 0000000000..6df88d8432
--- /dev/null
+++ b/testsuite/tests/codeGen/should_compile/T15196.hs
@@ -0,0 +1,4 @@
+module M where
+
+f :: Double -> Double -> Bool
+f x y = if x < y then True else False
diff --git a/testsuite/tests/codeGen/should_compile/T15196.stdout b/testsuite/tests/codeGen/should_compile/T15196.stdout
new file mode 100644
index 0000000000..56a6051ca2
--- /dev/null
+++ b/testsuite/tests/codeGen/should_compile/T15196.stdout
@@ -0,0 +1 @@
+1 \ No newline at end of file
diff --git a/testsuite/tests/codeGen/should_compile/all.T b/testsuite/tests/codeGen/should_compile/all.T
index 9118b6c23b..dd6931f235 100644
--- a/testsuite/tests/codeGen/should_compile/all.T
+++ b/testsuite/tests/codeGen/should_compile/all.T
@@ -43,3 +43,9 @@ test('T14999',
unless(opsys('linux') and arch('x86_64') and have_gdb() and
have_readelf(), skip)],
run_command, ['$MAKE -s --no-print-directory T14999'])
+
+# Verify that we optimize away redundant jumps for unordered comparisons.
+test('T15196',
+ [ unless(arch('x86_64'),skip),
+ only_ways('normal'),
+ ], run_command, ['$MAKE -s --no-print-directory T15196'])