> Am 03.02.2023 um 16:54 schrieb Andrew MacLeod <amacl...@redhat.com>:
> 
> 
>> On 2/2/23 07:22, Richard Biener wrote:
>>> On Wed, Feb 1, 2023 at 7:12 PM Andrew MacLeod via Gcc-patches
>>> <gcc-patches@gcc.gnu.org> wrote:
>>> We can reset SCEV after we fold, then SCEVs cache shouldn't have
>>> anything in it when we go to remove ssa-names in remove_unreachable().
>>> 
>>> We were resetting it later sometimes if we were processing the array
>>> bounds warning, so I removed that call and just always reset it now.
>>> 
>>> Bootstraps on x86_64-pc-linux-gnu. Testing running. Assuming no
>>> regressions,  OK for trunk?
>> +
>> +  // SCEV needs to be reset for array bounds, and we do not wish to trigger
>> +  // any SCEV lookups when removing unreachable globals, so reset it here.
>> +  scev_reset ();
>> 
>> the comment suggests that SCEV queries (aka analyze_scalar_evolution)
>> won't return anything after a scev_reset ().  That's not true - instead what
>> it does is nuke the SCEV cache.  That's necessary when you
>> release SSA names or alter the CFG and you want to avoid followup
>> SCEV queries to pick up stale data.
>> 
>> So if remove_and_update_globals performs SCEV queries and eventually
>> releases SSA names you cannot remove the second call to scev_reset.
>> 
>> But yes, it's probably substitute_and_fold_engine::substitute_and_fold
>> itself that should do a
>> 
>>   if (scev_initialized_p ())
>>     scev_reset ();
>> 
>> possibly only in the case it released an SSA name, or removed an
>> edge (but that's maybe premature optimization).
>> 
>> Richard.
>> 
>> 
> Mmm, yeah thats not what I meant to imply.  We can simply reset it before 
> trying to process the unreachable globals like so. Maybe we visit the  S&F 
> engine next release.. It seems more intrusive than this.
> 
> How about this patch?  testing underway.

Lgtm

Richard 
> Andrew
> 
> <0001-Reset-SCEV-before-removing-unreachable-globals.patch>

Reply via email to