[GHC] #15196: Invert floating point comparisons such that no extra parity check is required.

GHC ghc-devs at haskell.org
Tue Sep 18 17:06:43 UTC 2018


#15196: Invert floating point comparisons such that no extra parity check is
required.
-------------------------------------+-------------------------------------
        Reporter:  AndreasK          |                Owner:  AndreasK
            Type:  task              |               Status:  patch
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler (NCG)    |              Version:  8.4.3
      Resolution:                    |             Keywords:  CodeGen
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4990
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Krzysztof Gogolewski <krz.gogolewski@…>):

 In [changeset:"6bb9bc7d3c935dcb77e0700cce28de2c9df646df/ghc" 6bb9bc7/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="6bb9bc7d3c935dcb77e0700cce28de2c9df646df"
 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
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15196#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list