On Sat, Oct 25, 2025 at 2:54 AM Tamar Christina <[email protected]> wrote: > > The new building APIs e.g. gimple_build APIs at the moment ICE if you try to > build a PHI node without all the arguments set yet. However this workflow is > quite common, especially in the vectorizer. > > This change allows this case by just not folding the PHI is any argument is > missing as we don't know the value, we also don't know if it's nonnegative. > > Bootstrapped Regtested on aarch64-none-linux-gnu, > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > -m32, -m64 and no issues > > Ok for master?
I ran into the same issue before and Richi rejected a similar patch; I was also checking if the ssa name was in the free list. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120280#c10 and afterwards . That is the match.pd patterns are broken for not passing down the valueizer and checking the results there. I have not looked into cleaning up the mess either :(. Thanks, Andrew > > Thanks, > Tamar > > gcc/ChangeLog: > > * gimple-fold.cc (gimple_phi_nonnegative_warnv_p): If the arguments > aren't defined, then return false. > > --- > diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc > index > edcc04adc08cf15cff36d436caa31c0cfbff8f9a..bed760b9c0d538e2f874f5a1263a0d2db5486a86 > 100644 > --- a/gcc/gimple-fold.cc > +++ b/gcc/gimple-fold.cc > @@ -11386,7 +11386,9 @@ gimple_phi_nonnegative_warnv_p (gimple *stmt, bool > *strict_overflow_p, > for (unsigned i = 0; i < gimple_phi_num_args (stmt); ++i) > { > tree arg = gimple_phi_arg_def (stmt, i); > - if (!tree_single_nonnegative_warnv_p (arg, strict_overflow_p, depth + > 1)) > + if (!arg > + || !tree_single_nonnegative_warnv_p (arg, strict_overflow_p, > + depth + 1)) > return false; > } > return true; > > > --
