[PATCH] Fix PR63798

Richard Biener rguenther@suse.de
Mon Nov 10 10:03:00 GMT 2014


The following patch fixes a latent bug uncovered by stmt folding
that expansion of FMA_EXPR didn't consider the multiplication
commutative when looking for feeding negates.

Bootstrap & regtest pending.

Richard.

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

	PR middle-end/63798
	* expr.c (expand_expr_real_2): When expanding FMA_EXPRs
	properly treat the embedded multiplication as commutative
	when looking for feeding negates.

Index: gcc/expr.c
===================================================================
--- gcc/expr.c	(revision 217281)
+++ gcc/expr.c	(working copy)
@@ -8621,6 +8621,19 @@ expand_expr_real_2 (sepops ops, rtx targ
 	  }
 
 	def0 = get_def_for_expr (treeop0, NEGATE_EXPR);
+	/* The multiplication is commutative - look at its 2nd operand
+	   if the first isn't fed by a negate.  */
+	if (!def0)
+	  {
+	    def0 = get_def_for_expr (treeop1, NEGATE_EXPR);
+	    /* Swap operands if the 2nd operand is fed by a negate.  */
+	    if (def0)
+	      {
+		tree tem = treeop0;
+		treeop0 = treeop1;
+		treeop1 = tem;
+	      }
+	  }
 	def2 = get_def_for_expr (treeop2, NEGATE_EXPR);
 
 	op0 = op2 = NULL;



More information about the Gcc-patches mailing list