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]

[PATCH] Fix PR77514


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2016-09-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77514
	* tree-ssa-pre.c (create_expression_by_pieces): Handle garbage
	only forced_stmts sequence.

	* gcc.dg/torture/pr77514.c: New testcase.

Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c	(revision 240133)
+++ gcc/tree-ssa-pre.c	(working copy)
@@ -2879,7 +2879,21 @@ create_expression_by_pieces (basic_block
       gimple_seq_discard (forced_stmts);
       return folded;
     }
-
+  /* Likewise if we simplified to sth not queued for insertion.  */
+  bool found = false;
+  gsi = gsi_start (forced_stmts);
+  for (; !gsi_end_p (gsi); gsi_next (&gsi))
+    {
+      gimple *stmt = gsi_stmt (gsi);
+      tree forcedname = gimple_get_lhs (stmt);
+      if (forcedname == folded)
+	found = true;
+    }
+  if (! found)
+    {
+      gimple_seq_discard (forced_stmts);
+      return folded;
+    }
   gcc_assert (TREE_CODE (folded) == SSA_NAME);
 
   /* If we have any intermediate expressions to the value sets, add them
Index: gcc/testsuite/gcc.dg/torture/pr77514.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr77514.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr77514.c	(working copy)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+void
+m1 (char l0, char e8, int hw)
+{
+  char *rs = &l0;
+
+yu:
+  l0 = 1;
+  while (l0 != 0)
+    {
+      l0 = -l0;
+      l0 += (*rs ^ (l0 &= 1));
+    }
+  for (;;)
+    {
+      if (hw != 0)
+	goto yu;
+      rs = &e8;
+    }
+}


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