summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr67859.c15
-rw-r--r--gcc/tree-ssa-pre.c13
4 files changed, 35 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6afa6910260..eb02d8b6c1c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a931b24adc9..8b27d2ec97f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..259b3810f10
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr67859.c
@@ -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;
+ }
+}
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index fb9ed02ec87..c5af63d8ca1 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -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);