aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-03-02 16:02:37 +0000
committerJakub Jelinek <jakub@redhat.com>2017-03-02 16:02:37 +0000
commit32a9a3cefe40895335ce9c31f8c2c9c1835e8100 (patch)
tree036c24db59cfd5f9166e68ab892452c1abf3df5d
parent7bf43cee71a9434e322da2d094622a70e3a7ad28 (diff)
PR rtl-optimization/79780
* cprop.c (one_cprop_pass): When second and further conditional trap in a single basic block is turned into an unconditional trap, turn it into a deleted note to avoid RTL verification failures. * gcc.c-torture/compile/pr79780.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@245843 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cprop.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr79780.c48
4 files changed, 73 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d5e438c883f..4663d438a91 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2017-03-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/79780
+ * cprop.c (one_cprop_pass): When second and further conditional trap
+ in a single basic block is turned into an unconditional trap, turn it
+ into a deleted note to avoid RTL verification failures.
+
2017-03-02 Richard Biener <rguenther@suse.de>
* fold-const.c (const_binop): Use ulow () instead of elt (0).
diff --git a/gcc/cprop.c b/gcc/cprop.c
index 7d20c4434b6..4814b5e97c0 100644
--- a/gcc/cprop.c
+++ b/gcc/cprop.c
@@ -1852,12 +1852,22 @@ one_cprop_pass (void)
if (! NOTE_P (insn) && ! insn->deleted ())
mark_oprs_set (insn);
- if (!was_uncond_trap && !seen_uncond_trap
+ if (!was_uncond_trap
&& GET_CODE (PATTERN (insn)) == TRAP_IF
&& XEXP (PATTERN (insn), 0) == const1_rtx)
{
- seen_uncond_trap = true;
- uncond_traps.safe_push (insn);
+ /* If we have already seen an unconditional trap
+ earlier, the rest of the bb is going to be removed
+ as unreachable. Just turn it into a note, so that
+ RTL verification doesn't complain about it before
+ it is finally removed. */
+ if (seen_uncond_trap)
+ set_insn_deleted (insn);
+ else
+ {
+ seen_uncond_trap = true;
+ uncond_traps.safe_push (insn);
+ }
}
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bb5d68f0477..3eca2ab2194 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/79780
+ * gcc.c-torture/compile/pr79780.c: New test.
+
2017-03-02 Richard Biener <rguenther@suse.de>
PR tree-optimization/79345
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr79780.c b/gcc/testsuite/gcc.c-torture/compile/pr79780.c
new file mode 100644
index 00000000000..c50708d9ada
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr79780.c
@@ -0,0 +1,48 @@
+/* PR rtl-optimization/79780 */
+
+int t3, iy, f4, oi, gn;
+
+void
+foo (long long int mh)
+{
+ int pi = 0;
+
+ if (iy != 0)
+ for (;;)
+ f4 = 0;
+
+ if (t3 != 0)
+ {
+ while (mh != 0LL)
+ {
+ while (mh < 1LL)
+ ++mh;
+ ++mh;
+ }
+ for (;;)
+ ;
+ for (oi = 0; oi < 1; ++oi)
+ {
+ n3:;
+ }
+ gn = iy = 1;
+ }
+
+ f4 = 0;
+
+ if (pi - (mh != 0LL) == 0)
+ if (mh != 1LL)
+ {
+ oi = t3 = 0;
+ if (mh == 0LL)
+ ++pi;
+ }
+
+ if (iy != 0 && pi != 0)
+ {
+ t3 = 0;
+ goto n3;
+ }
+
+ t3 /= 0;
+}