This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR58775


On Mon, Oct 21, 2013 at 01:20:06PM +0800, Zhenqiang Chen wrote:
> Thanks for the comments.
> 
> Patch is updated to set uid in update_range_test after force_gimple_operand_gsi.
> 
> I am not sure the patch can cover all cases. If not, I think
> force_gimple_operand_gsi_1 maybe the only place to set uid for all new
> generated statements.

No, force_gimple_operand_gsi can add more than one stmt, thus I think it is
appropriate to do this instead (or force_gimple_operand_1 into a gimple_seq,
set uid on all stmts in that seq and then insert them).

OT, the other force_gimple_operand_gsi in negate_value lead me to a thought
that we could avoid the extra walk of all the IL in do_reassoc ->
renumber_gimple_stmt_uids by setting the uids in break_up_subtract_bb,
where we already reset the visited flags to avoid the extra IL walk.

2013-10-21  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/58775
	* tree-ssa-reassoc.c (update_range_test): Set uid on stmts added by
	force_gimple_operand_gsi.

	* gcc.c-torture/compile/pr58775.c: New test.

--- gcc/tree-ssa-reassoc.c.jj	2013-10-21 09:00:25.000000000 +0200
+++ gcc/tree-ssa-reassoc.c	2013-10-21 09:47:24.431082049 +0200
@@ -2011,6 +2011,11 @@ update_range_test (struct range_entry *r
   gsi = gsi_for_stmt (stmt);
   tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,
 				  GSI_SAME_STMT);
+  for (gsi_prev (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
+    if (gimple_uid (gsi_stmt (gsi)))
+      break;
+    else
+      gimple_set_uid (gsi_stmt (gsi), gimple_uid (stmt));
 
   /* If doing inter-bb range test optimization, update the
      stmts immediately.  Start with changing the first range test
--- gcc/testsuite/gcc.c-torture/compile/pr58775.c.jj	2013-10-21 09:48:34.034726581 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr58775.c	2013-10-21 09:48:47.029662347 +0200
@@ -0,0 +1,26 @@
+/* PR tree-optimization/58775 */
+
+void bar (void);
+
+void
+foo (char *x)
+{
+  char a;
+  _Bool b, c, d, e, f, g, h, i, j, k, l, m;
+
+  a = *x;
+  b = a == 100;
+  c = a == 105;
+  d = b | c;
+  e = a != 111;
+  f = !d;
+  g = e & f;
+  h = a != 117;
+  i = g & h;
+  j = a != 120;
+  k = i & j;
+  l = a != 88;
+  m = k & l;
+  if (m == 0)
+    bar ();
+}


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]