The following code in from cmm/CmmMachOps.hs (lines 255-282) looks very wrong:

======================================================
-- Inverting conditions

-- Sometimes it's useful to be able to invert the sense of a
-- condition.  Not all conditional tests are invertible: in
-- particular, floating point conditionals cannot be inverted, because
-- there exist floating-point values which return False for both senses
-- of a condition (eg. !(NaN > NaN) && !(NaN /<= NaN)).

maybeInvertComparison :: MachOp -> Maybe MachOp
maybeInvertComparison op
  = case op of  -- None of these Just cases include floating point
        MO_Eq r   -> Just (MO_Ne r)
        MO_Ne r   -> Just (MO_Eq r)
        MO_U_Lt r -> Just (MO_U_Ge r)
        MO_U_Gt r -> Just (MO_U_Le r)
        MO_U_Le r -> Just (MO_U_Gt r)
        MO_U_Ge r -> Just (MO_U_Lt r)
        MO_S_Lt r -> Just (MO_S_Ge r)
        MO_S_Gt r -> Just (MO_S_Le r)
        MO_S_Le r -> Just (MO_S_Gt r)
        MO_S_Ge r -> Just (MO_S_Lt r)
        MO_F_Eq r -> Just (MO_F_Ne r)  -- <-- this might be ok
        MO_F_Ne r -> Just (MO_F_Eq r)  -- <-- this, too
        MO_F_Ge r -> Just (MO_F_Le r)  -- <-- definitely wrong
        MO_F_Le r -> Just (MO_F_Ge r)  -- <-- definitely wrong
        MO_F_Gt r -> Just (MO_F_Lt r)  -- <-- definitely wrong
        MO_F_Lt r -> Just (MO_F_Gt r)  -- <-- definitely wrong
        _other    -> Nothing
======================================================

Note, how those six lines contradict the two comments above it and the
latter four lines are just completely off.

It looks it was introduced by John Dias in commit
176fa33f17dd78355cc572e006d2ab26898e2c69.  It was a megacommit right
in the middle of the time when he was getting the new GC working, so
it's quite likely that the code has never been reviewed properly.
Those are also also quite difficult to test for, and I'm not sure our
GC tests are that thorough.  It could be that this code is never
actually used in the current code path, of course.

I currently don't have time to set up a working GHC tree and verify
and fix this, so I figured I'll let the list know in the hopes that
someone else has can find some time to do so.

/ Thomas

_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to