re PR tree-optimization/67859 (ICE on valid code at -O2 and -O3 on x86_64-linux-gnu)
authorRichard Biener <rguenther@suse.de>
Tue, 6 Oct 2015 12:34:15 +0000 (12:34 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 6 Oct 2015 12:34:15 +0000 (12:34 +0000)
2015-10-06  Richard Biener  <rguenther@suse.de>

PR tree-optimization/67859
* tree-ssa-pre.c (create_expression_by_pieces): Properly
discard not inserted stmts.

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

From-SVN: r228519

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr67859.c [new file with mode: 0644]
gcc/tree-ssa-pre.c

index 6afa691026093f8002c4fa59cc9cbf6ef069a13f..eb02d8b6c1c55b0a8391dbc741c22f7849df9852 100644 (file)
@@ -1,3 +1,9 @@
+2015-10-06  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/67859
+       * tree-ssa-pre.c (create_expression_by_pieces): Properly
+       discard not inserted stmts.
+
 2015-10-06  Jonathan Wakely  <jwakely@redhat.com>
 
        * doc/extend.texi (Template Instantiation): Reorder options and
index a931b24adc9893743ac652350a6194d6eedfd3df..8b27d2ec97f4ee8b4890663b64193d63337d3726 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-06  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/67859
+       * gcc.dg/torture/pr67859.c: New testcase.
+
 2015-10-05  Kirill Yukhin  <kirill.yukhin@intel.com>
 
        * gcc.target/i386/builtin_target.c: Add check for AES and PCLMUL.
diff --git a/gcc/testsuite/gcc.dg/torture/pr67859.c b/gcc/testsuite/gcc.dg/torture/pr67859.c
new file mode 100644 (file)
index 0000000..259b381
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+int a, b, c;
+
+void
+fn1 ()
+{
+  b = c ? 0 : 1 << a;
+  b |= 0x9D7A5FD9;
+  for (;;)
+    {
+      int d = 1;
+      b &= (unsigned) d;
+    }
+}
index fb9ed02ec87184413d9cac334c08f7b64f510b15..c5af63d8ca17ca82738ca9c429dbf8dde3071630 100644 (file)
@@ -2897,11 +2897,16 @@ create_expression_by_pieces (basic_block block, pre_expr expr,
 
   folded = gimple_convert (&forced_stmts, exprtype, folded);
 
-  /* If everything simplified to an exisiting SSA name or constant just
-     return that.  */
-  if (gimple_seq_empty_p (forced_stmts)
-      || is_gimple_min_invariant (folded))
+  /* If there is nothing to insert, return the simplified result.  */
+  if (gimple_seq_empty_p (forced_stmts))
     return folded;
+  /* If we simplified to a constant return it and discard eventually
+     built stmts.  */
+  if (is_gimple_min_invariant (folded))
+    {
+      gimple_seq_discard (forced_stmts);
+      return folded;
+    }
 
   gcc_assert (TREE_CODE (folded) == SSA_NAME);