[GHC] #15196: Invert floating point comparisons such that no extra parity check is required.
GHC
ghc-devs at haskell.org
Wed May 30 11:01:23 UTC 2018
#15196: Invert floating point comparisons such that no extra parity check is
required.
-------------------------------------+-------------------------------------
Reporter: AndreasK | Owner: (none)
Type: task | Status: new
Priority: normal | Milestone: 8.6.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):
Wiki Page: |
-------------------------------------+-------------------------------------
Description changed by AndreasK:
Old description:
> This comment pretty much explains it already:
>
> {{{
> -- We have to worry about unordered operands (eg. comparisons
> -- against NaN). If the operands are unordered, the comparison
> -- sets the parity flag, carry flag and zero flag.
> -- All comparisons are supposed to return false for unordered
> -- operands except for !=, which returns true.
> --
> -- 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.
> --
> -- ToDo: by reversing comparisons we could avoid testing the
> -- parity flag in more cases.
> }}}
New description:
This comment pretty much explains it already:
{{{
-- We have to worry about unordered operands (eg. comparisons
-- against NaN). If the operands are unordered, the comparison
-- sets the parity flag, carry flag and zero flag.
-- All comparisons are supposed to return false for unordered
-- operands except for !=, which returns true.
--
-- 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.
--
-- ToDo: by reversing comparisons we could avoid testing the
-- parity flag in more cases.
}}}
This would turn a sequence of
{{{
jp foo
jb bar
jmp foo
}}}
into:
{{{
jge foo
jmp bar
}}}
--
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15196#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list