diff mbox

Fix copy&paste error in fold

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

Commit Message

Richard Biener Oct. 23, 2014, 1:42 p.m. UTC
The following makes sure to convert the correct argument, not the
one we already converted.  Currently we end up folding
ptr-type - integer-type.  Oops.  Fails spectacularly on 
match-and-simplify where this is the first strip-nops
missed-optimization (on bogus input, that is).

I'm considering this is obvious but will include it in a bootstrap/regtest
anyway.

Thanks,
Richard.

2014-10-23  Richard Biener  <rguenther@suse.de>

	* fold-const.c (fold_binary_loc): Fix copy-and-pasto.
diff mbox

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 216546)
+++ gcc/fold-const.c	(working copy)
@@ -10596,8 +10596,9 @@  fold_binary_loc (location_t loc,
 					     TREE_OPERAND (arg1, 0));
 	      tree arg11 = fold_convert_loc (loc, type,
 					     TREE_OPERAND (arg1, 1));
-	      tree tmp = fold_binary_loc (loc, MINUS_EXPR, type, arg0,
-					  fold_convert_loc (loc, type, arg10));
+	      tree tmp = fold_binary_loc (loc, MINUS_EXPR, type,
+					  fold_convert_loc (loc, type, arg0),
+					  arg10);
 	      if (tmp)
 		return fold_build2_loc (loc, MINUS_EXPR, type, tmp, arg11);
 	    }