[PATCH, Fix PR 31098] a*C == b*C is not foldded to a == b with --fast-math/floating point
Paolo Bonzini
bonzini@gnu.org
Mon Oct 8 07:42:00 GMT 2007
>> 2007-10-07 Pranav Bhandarkar <pranav.bhandarkar@celunite.com>
>>
>> * fold-const.c (fold_comparison): fold (a OP c) CMP (b OP c) -> a
>> CMP b, iff c is not zero
>> * testsuite/pr31098.c: New
>
>> + /* (a OP c) CMP (b OP c) -> a CMP b, iff c is not zero */
>> + if (fast_math_flags_set_p () && (TREE_CODE (arg0) == TREE_CODE (arg1))
>
> Do we really need all "fast math" flags set to enable this opt? E.g.
> surely we don't care about !flag_signed_zeros since you disable the code
> when "c" is zero. Perhaps other sub-bits of "fast math" can also be
> ignored for this purpose.
flag_unsafe_math_optimizations == 0 should disable the optimization,
since ((float)11184813.0 * 3) == ((float)11184814.0 * 3), and
((float)16777215.0 + 2) == ((float)16777214.0 + 2). Same for
HONOR_INFINITIES, and for flag_trapping_math == 1.
It is not necessary to check HONOR_NANS and HONOR_SNANS, since neither
is set for flag_trapping_math == 0.
Paolo
More information about the Gcc-patches
mailing list