Skip to content
  • Andreas Klebinger's avatar
    Invert FP conditions to eliminate the explicit NaN check. · 6bb9bc7d
    Andreas Klebinger authored and Krzysztof Gogolewski's avatar Krzysztof Gogolewski committed
    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
    6bb9bc7d