Invert FP conditions to eliminate the explicit NaN check.
authorklebinger.andreas@gmx.at <klebinger.andreas@gmx.at>
Tue, 18 Sep 2018 15:46:38 +0000 (17:46 +0200)
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>
Tue, 18 Sep 2018 17:05:56 +0000 (19:05 +0200)
commit6bb9bc7d3c935dcb77e0700cce28de2c9df646df
tree04a5d2e6466e626b3b60f83e62ffae418463678b
parentce3897ffd6e7c8b8f36b8e920168bac8c7f836ae
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
compiler/nativeGen/X86/CodeGen.hs
testsuite/tests/codeGen/should_compile/Makefile
testsuite/tests/codeGen/should_compile/T15196.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_compile/T15196.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_compile/all.T