[PATCH] Fix reassoci ICE (PR tree-optimization/68157)

Jakub Jelinek jakub@redhat.com
Wed Nov 18 08:44:00 GMT 2015


Hi!

attempt_builtin_powi and its caller does not set uids of the stmts it adds,
which in some cases may lead to reassoc ICEs.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk/5.3?

2015-11-18  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/68157
	* tree-ssa-reassoc.c (attempt_builtin_powi): Set uid of
	pow_stmt or mul_stmt from stmt's uid.
	(reassociate_bb): Set uid of mul_stmt from stmt's uid.

	* g++.dg/opt/pr68157.C: New test.

--- gcc/tree-ssa-reassoc.c.jj	2015-11-04 11:12:19.000000000 +0100
+++ gcc/tree-ssa-reassoc.c	2015-11-16 12:46:51.749495480 +0100
@@ -4451,6 +4451,7 @@ attempt_builtin_powi (gimple *stmt, vec<
 							   power));
 	      gimple_call_set_lhs (pow_stmt, iter_result);
 	      gimple_set_location (pow_stmt, gimple_location (stmt));
+	      gimple_set_uid (pow_stmt, gimple_uid (stmt));
 	      gsi_insert_before (&gsi, pow_stmt, GSI_SAME_STMT);
 
 	      if (dump_file && (dump_flags & TDF_DETAILS))
@@ -4534,6 +4535,7 @@ attempt_builtin_powi (gimple *stmt, vec<
 		  mul_stmt = gimple_build_assign (target_ssa, MULT_EXPR,
 						  op1, op2);
 		  gimple_set_location (mul_stmt, gimple_location (stmt));
+		  gimple_set_uid (mul_stmt, gimple_uid (stmt));
 		  gsi_insert_before (&gsi, mul_stmt, GSI_SAME_STMT);
 		  rf1->repr = target_ssa;
 
@@ -4551,6 +4553,7 @@ attempt_builtin_powi (gimple *stmt, vec<
 						       power));
 	  gimple_call_set_lhs (pow_stmt, iter_result);
 	  gimple_set_location (pow_stmt, gimple_location (stmt));
+	  gimple_set_uid (pow_stmt, gimple_uid (stmt));
 	  gsi_insert_before (&gsi, pow_stmt, GSI_SAME_STMT);
 	}
 
@@ -4562,6 +4565,7 @@ attempt_builtin_powi (gimple *stmt, vec<
 	  mul_stmt = gimple_build_assign (new_result, MULT_EXPR,
 					  result, iter_result);
 	  gimple_set_location (mul_stmt, gimple_location (stmt));
+	  gimple_set_uid (mul_stmt, gimple_uid (stmt));
 	  gsi_insert_before (&gsi, mul_stmt, GSI_SAME_STMT);
 	  gimple_set_visited (mul_stmt, true);
 	  result = new_result;
@@ -4919,6 +4923,7 @@ reassociate_bb (basic_block bb)
 		      mul_stmt = gimple_build_assign (lhs, MULT_EXPR,
 						      powi_result, target_ssa);
 		      gimple_set_location (mul_stmt, gimple_location (stmt));
+		      gimple_set_uid (mul_stmt, gimple_uid (stmt));
 		      gsi_insert_after (&gsi, mul_stmt, GSI_NEW_STMT);
 		    }
 		}
--- gcc/testsuite/g++.dg/opt/pr68157.C.jj	2015-11-16 12:41:41.583871551 +0100
+++ gcc/testsuite/g++.dg/opt/pr68157.C	2015-11-16 12:54:30.613990591 +0100
@@ -0,0 +1,18 @@
+// PR tree-optimization/68157
+// { dg-do compile }
+// { dg-options "-Ofast" }
+
+double a, b, c, d;
+int h, foo ();
+
+void
+bar ()
+{
+  while (foo ())
+    {
+      double e = b * a * a;
+      double f = b * d;
+      if (h)
+	c = e + f;
+    }
+}

	Jakub



More information about the Gcc-patches mailing list