Floating-point comparisons in the middle-end

Marc Glisse marc.glisse@inria.fr
Thu Sep 1 15:57:21 GMT 2022


On Thu, 1 Sep 2022, Joseph Myers wrote:

> On Thu, 1 Sep 2022, FX via Gcc wrote:
>
>> A tentative patch is attached, it seems to work well on simple examples,
>> but for test coverage the hard part is going to be that the comparisons
>> seem to be optimised away very easily into their non-signaling versions.
>> Basically, if I do:
>
> Presumably that can be reproduced without depending on the new built-in
> function?  In which case it's an existing bug somewhere in the optimizers.

  (simplify
   (cmp @0 REAL_CST@1)
[...]
    (if (REAL_VALUE_ISNAN (TREE_REAL_CST (@1))
         && !tree_expr_signaling_nan_p (@1)
         && !tree_expr_maybe_signaling_nan_p (@0))
     { constant_boolean_node (cmp == NE_EXPR, type); })

only tries to preserve a comparison with sNaN, but not with qNaN. There 
are probably other issues since various gcc devs used to have a different 
opinion on the meaning of -ftrapping-math.


-- 
Marc Glisse


More information about the Gcc mailing list