Patchwork Fix PR50082

login
register
mail settings
Submitter Richard Guenther
Date Aug. 15, 2011, 3 p.m.
Message ID <alpine.LNX.2.00.1108151658510.810@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/110046/
State New
Headers show

Comments

Richard Guenther - Aug. 15, 2011, 3 p.m.
This "fixes" PR50082 by passing comparison operands stripped off
useless conversions to the canonicalization routine.  This makes
sure to fold the testcase early from a point where emitting
a overflow warning is properly constrained.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-08-15  Richard Guenther  <rguenther@suse.de>

	PR middle-end/50082
	* fold-const.c (maybe_canonicalize_comparison_1): Properly
	convert the modified operand to the other operand type.
	(fold_comparison): Call maybe_canonicalize_comparison_1 with
	useless conversions stripped from comparison operands.

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 177757)
+++ gcc/fold-const.c	(working copy)
@@ -8446,6 +8446,7 @@  maybe_canonicalize_comparison_1 (locatio
 		       cst0, build_int_cst (TREE_TYPE (cst0), 1));
   if (code0 != INTEGER_CST)
     t = fold_build2_loc (loc, code0, TREE_TYPE (arg0), TREE_OPERAND (arg0, 0), t);
+  t = fold_convert (TREE_TYPE (arg1), t);
 
   /* If swapping might yield to a more canonical form, do so.  */
   if (swap)
@@ -8935,7 +8936,7 @@  fold_comparison (location_t loc, enum tr
       return fold_build2_loc (loc, cmp_code, type, variable1, const2);
     }
 
-  tem = maybe_canonicalize_comparison (loc, code, type, op0, op1);
+  tem = maybe_canonicalize_comparison (loc, code, type, arg0, arg1);
   if (tem)
     return tem;