I missed that factor_out_operators might look further up when it is doing its
factoring so we end up with a statement that ssa names that are used in abnormal
edges.
This changes the asserts to just reject the factoring instead.
Bootstrapped and tested on x86_64-linx-gnu.
PR tree-optimization/125419
gcc/ChangeLog:
* tree-if-conv.cc (factor_out_operators): Change
asserts about abnormals into a conditional to reject
it.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr125419-1.c: New test.
Signed-off-by: Andrew Pinski <[email protected]>
(cherry picked from commit b57b0a72eb482eeeb2572119a0a362869d5b957a)
---
gcc/testsuite/gcc.dg/torture/pr125419-1.c | 23 +++++++++++++++++++++++
gcc/tree-if-conv.cc | 10 ++++++----
2 files changed, 29 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr125419-1.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr125419-1.c
b/gcc/testsuite/gcc.dg/torture/pr125419-1.c
new file mode 100644
index 00000000000..281df950191
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr125419-1.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* PR tree-optimization/125419 */
+
+signed g13, g29, g27, g26, g17;
+void f2(void)__attribute__((returns_twice));
+void f1(bool c14)
+{
+ int sj15;
+ if (c14) sj15 = sj15;
+ f2();
+ c14 = 0;
+ do {
+ int c11 = g27;
+ if (c11) goto lbl_br22;
+ goto lbl_br24;
+lbl_br22:
+ c14 = sj15;
+ c11 = g29 = g13;
+ if (c11) goto lbl_br22;
+lbl_br24:
+ g26 = g17;
+ } while (c14);
+}
diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc
index d728f7c5221..218d2cb7238 100644
--- a/gcc/tree-if-conv.cc
+++ b/gcc/tree-if-conv.cc
@@ -2277,15 +2277,17 @@ again:
if (!gimple_extract_op (arg0_def_stmt, &arg0_op))
return;
- /* At this point there should be no ssa names occuring in abnormals. */
- gcc_assert (!arg0_op.operands_occurs_in_abnormal_phi ());
+ /* Might pick up abnormals from previous bbs so stop the loop. */
+ if (arg0_op.operands_occurs_in_abnormal_phi ())
+ return;
gimple *arg1_def_stmt = SSA_NAME_DEF_STMT (*arg1);
if (!gimple_extract_op (arg1_def_stmt, &arg1_op))
return;
- /* At this point there should be no ssa names occuring in abnormals. */
- gcc_assert (!arg1_op.operands_occurs_in_abnormal_phi ());
+ /* Might pick up abnormals from previous bbs so stop the loop. */
+ if (arg1_op.operands_occurs_in_abnormal_phi ())
+ return;
/* No factoring can happen if the codes are different
or the number operands. */
--
2.43.0