On Wed, Apr 05, 2023 at 04:10:25PM -0400, Andrew MacLeod via Gcc-patches wrote: > When a statement is first processed, any SSA_NAMEs that are dependencies are > cached for quick future access. > > if we ;later rewrite the statement (say propagate a constant into it), its > possible the ssa-name in this cache is no longer active. Normally this is > not a problem, but the changed to may_recompute_p forgot to take that into > account, and was checking a dependency from the cache that was in the > SSA_NAME_FREE_LIST. It thus had no SSA_NAME_DEF_STMT when we were expecting > one. > > This patch simply rejects dependencies from consideration if they are in the > free list. > > Bootstrapping on x86_64-pc-linux-gnu and presuming no regressio0ns, OK for > trunk? > > Andrew
> commit ecd86e159e8499feb387bc4d99bd37a5fd6a0d68 > Author: Andrew MacLeod <amacl...@redhat.com> > Date: Wed Apr 5 15:59:38 2023 -0400 > > Check if dependency is valid before using in may_recompute_p. > > When the IL is rewritten after a statement has been processed and > dependencies cached, its possible that an ssa-name in the dependency > cache is no longer in the IL. Check this before trying to recompute. > > PR tree-optimization/109417 > gcc/ > * gimple-range-gori.cc (gori_compute::may_recompute_p): Check if > dependency is in SSA_NAME_FREE_LIST. > > gcc/testsuite/ > * gcc.dg/pr109417.c: New. Ok for trunk (mainly to unbreak the recent regression). But please be ready to adjust if Richi disagrees next week. > --- a/gcc/gimple-range-gori.cc > +++ b/gcc/gimple-range-gori.cc > @@ -1314,7 +1314,9 @@ gori_compute::may_recompute_p (tree name, basic_block > bb, int depth) > tree dep2 = depend2 (name); > > // If the first dependency is not set, there is no recomputation. > - if (!dep1) > + // Dependencies reflect original IL, not current state. Check if the > + // SSA_NAME is still valid as well. > + if (!dep1 || SSA_NAME_IN_FREE_LIST (dep1)) > return false; > > // Don't recalculate PHIs or statements with side_effects. Jakub