Opened 3 months ago

Last modified 3 days ago

#15196 patch task

Invert floating point comparisons such that no extra parity check is required.

Reported by: AndreasK Owned by: AndreasK
Priority: normal Milestone: 8.8.1
Component: Compiler (NCG) Version: 8.4.3
Keywords: CodeGen Cc:
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:

Description (last modified by AndreasK)

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

Change History (5)

comment:1 Changed 3 months ago by AndreasK

Description: modified (diff)

comment:2 Changed 8 weeks ago by bgamari

Milestone: 8.6.18.8.1

These won't be addressed for GHC 8.6.

comment:3 Changed 4 weeks ago by AndreasK

Differential Rev(s): Phab:D4990

There is a patch but it's still buggy atm.

comment:4 Changed 3 days ago by AndreasK

Owner: set to AndreasK

comment:5 Changed 3 days ago by AndreasK

Status: newpatch

Ready for merge from my PoV

Note: See TracTickets for help on using tickets.