diff mbox

Fix genmatch SAVE_TEMPS usage for multi-uses

Message ID alpine.LSU.2.11.1511261435530.4884@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Nov. 26, 2015, 1:37 p.m. UTC
This fixes the issue that genmatch wraps captures in SAVE_TEMPS
only for correctness reasons right now (for TREE_SIDE_EFFECTS
captures) but not to avoid duplicating expensive computations.

The following fixes that.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk,
testing on the branch right now.

Richard.

2015-11-26  Richard Biener  <rguenther@suse.de>

	* genmatch.c (dt_simplify::gen_1): For generic wrap all
	multi-result-use captures in a SAVE_EXPR.
diff mbox

Patch

Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	(revision 230924)
+++ gcc/genmatch.c	(working copy)
@@ -3112,16 +3111,10 @@  dt_simplify::gen_1 (FILE *f, int indent,
 	      {
 		if (cinfo.info[i].same_as != (unsigned)i)
 		  continue;
-		if (!cinfo.info[i].force_no_side_effects_p
-		    && cinfo.info[i].result_use_count > 1)
-		  {
-		    fprintf_indent (f, indent,
-				    "if (TREE_SIDE_EFFECTS (captures[%d]))\n",
-				    i);
-		    fprintf_indent (f, indent,
-				    "  captures[%d] = save_expr (captures[%d]);\n",
-				    i, i);
-		  }
+		if (cinfo.info[i].result_use_count > 1)
+		  fprintf_indent (f, indent,
+				  "captures[%d] = save_expr (captures[%d]);\n",
+				  i, i);
 	      }
 	  for (unsigned j = 0; j < e->ops.length (); ++j)
 	    {