]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ifcvt: factor: turn asserts about abnormals to conditional [PR125419]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Fri, 22 May 2026 19:07:28 +0000 (12:07 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sun, 24 May 2026 14:53:02 +0000 (07:53 -0700)
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 <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/gcc.dg/torture/pr125419-1.c [new file with mode: 0644]
gcc/tree-if-conv.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr125419-1.c b/gcc/testsuite/gcc.dg/torture/pr125419-1.c
new file mode 100644 (file)
index 0000000..281df95
--- /dev/null
@@ -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);
+}
index d728f7c5221c66c2fd963d3e3ab55b232e628cb0..218d2cb72386c5f6cc9906494589f90bef42b487 100644 (file)
@@ -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.  */