[PATCH] Canonicalize comparisons, fix PR26899
Roger Sayle
roger@eyesopen.com
Sat Oct 28 17:37:00 GMT 2006
On Sat, 28 Oct 2006, Richard Guenther wrote:
> > I think there's an potential problem here that you're not checking
> > whether the CST-1 operation overflowed.
>
> The CST +- 1 operation cannot overflow, as it is assured perviously that
> CST is not zero and CST will decrease in magnitude by the constant
> adjustment (otherwise the transformation would be invalid as it might
> introduce undefined overflow).
Doh! My mistake, you're quite right.
> 2006-10-28 Richard Guenther <rguenther@suse.de>
>
> PR middle-end/26899
> * fold-const.c (maybe_canonicalize_comparison_1): Helper
> for maybe_canonicalize_comparison.
> (maybe_canonicalize_comparison): New function for canonicalizing
> comparison trees.
> (fold_comparison): Call it to canonicalize comparisons with
> constants involved.
>
> * gcc.dg/tree-ssa/pr26899.c: New testcase.
This is OK for mainline. Thanks for the clean-up, and my apologies again
for missing that it was the magnitude of the constant you're reducing/
canonicalizing.
Roger
--
More information about the Gcc-patches
mailing list