diff mbox

[match-and-simplify] Fix some testcases

Message ID alpine.LSU.2.11.1408281032240.20733@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Aug. 28, 2014, 8:33 a.m. UTC
The following fixes a few ICEs and C++ testsuite fails.

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

Richard.

2014-08-28  Richard Biener  <rguenther@suse.de>

	* match-constant-folding.pd (x + 0 -> x): Wrap result in
	a NON_LVALUE_EXPR to account for the C++ frontend folding
	too early, avoding some spurious testsuite FAILs.
	* match-conversions.pd: Use convert where that's unconditionally
	required.
diff mbox

Patch

Index: gcc/match-constant-folding.pd
===================================================================
--- gcc/match-constant-folding.pd	(revision 214519)
+++ gcc/match-constant-folding.pd	(working copy)
@@ -20,6 +20,13 @@  along with GCC; see the file COPYING3.
 (for op in plus pointer_plus minus bit_ior bit_xor
   (simplify
     (op @0 integer_zerop)
+    (if (!in_gimple_form)
+      /* ???  fold_binary adds non_lvalue here and "fixes" the C++
+	 run of Wsizeof-pointer-memaccess1.c, preserving enough of
+	 sizeof (&a) + 0 because sizeof (&a) is maybe_lvalue_p ()
+	 for no good reason.  The C frontend is fine as it doesn't
+	 fold too early.  */
+     (non_lvalue @0))
     @0))
 
 (simplify
Index: gcc/match-conversions.pd
===================================================================
--- gcc/match-conversions.pd	(revision 214567)
+++ gcc/match-conversions.pd	(working copy)
@@ -101,7 +101,7 @@ 
 	&& ((inside_prec < inter_prec && inter_prec < final_prec
 	     && inside_unsignedp && !inter_unsignedp)
 	    || final_prec == inter_prec))
-    (ocvt @0))
+    (convert @0))
 
    /* Two conversions in a row are not needed unless:
 	- some conversion is floating-point (overstrict for now), or
@@ -134,10 +134,10 @@ 
 	&& final_prec == inside_prec
 	&& final_prec > inter_prec
 	&& inter_unsignedp)
-    (ocvt (bit_and @0 { wide_int_to_tree
-	      (inside_type,
-	       wi::mask (inter_prec, false,
-			 TYPE_PRECISION (inside_type))); })))
+    (convert (bit_and @0 { wide_int_to_tree
+	                     (inside_type,
+			      wi::mask (inter_prec, false,
+					TYPE_PRECISION (inside_type))); })))
 
    /* If we are converting an integer to a floating-point that can
       represent it exactly and back to an integer, we can skip the
@@ -145,4 +145,4 @@ 
    (if (inside_int && inter_float && final_int &&
 	(unsigned) significand_size (TYPE_MODE (inter_type))
 	>= inside_prec - !inside_unsignedp)
-    (ocvt @0))))))
+    (convert @0))))))