https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129266
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Before that change it is
# c_17(ab) = PHI <1(9), c_10(D)(2)>
# d_18 = PHI <d_11(ab)(9), 0(2)>
d_11(ab) = d_18 + 1;
_1 = e[c_17(ab)];
goto _1;
;; succ: 4
;; 7
;; basic block 4, loop depth 0
;; pred: 3
# d_6(ab) = PHI <d_11(ab)(3)>
# c_3(ab) = PHI <c_17(ab)(3)>
l1:
if (d_6(ab) == 1)
So, bb4 has a single predecessor but only reachable through abnormal edge.
Guess trying to optimize in this case (like the d_6(ab) == 1 to d_18 == 0) case
is dangerous, and I think it wouldn't be hard to
--- a/gcc/match.pd 2026-12-03 16:40:53.935819042 +0100
+++ b/gcc/match.pd 2026-12-03 17:46:45.576803221 +0100
@@ -11214,7 +11214,10 @@ x == ~x is impossible, so le/ge behave l
(if (TREE_OVERFLOW (res)
&& TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))
{ constant_boolean_node (cmp == NE_EXPR, type); }
- (if (single_use (@3) || wi::to_wide (res) == 0)
+ (if (single_use (@3)
+ || (wi::to_wide (res) == 0
+ && (TREE_CODE (@3) != SSA_NAME
+ || !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (@3))))
(cmp @0 { TREE_OVERFLOW (res)
? drop_tree_overflow (res) : res; }))))))))
(for cmp (lt le gt ge)
but am not sure if that is the right thing to do.
Note, maybe_push_res_to_seq has
/* Play safe and do not allow abnormals to be mentioned in
newly created statements. */
for (unsigned int i = 0; i < num_ops; ++i)
if (TREE_CODE (ops[i]) == SSA_NAME
&& SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[i]))
return NULL_TREE;
but that doesn't trigger here, we aren't adding any
SSA_NAME_OCCURS_IN_ABNORMAL_PHI nor they appear in any replacement, we are
instead removing them (which itself doesn't have to be a problem in cases like
@0 - @0 being replaced with 0, but here where we replace it with some part of
the (ab) def stmt it can be a problem.