This is an archive of the discontinued LLVM Phabricator instance.

[LoopFuse] Drop loop dispositions before reassigning blocks to other loop
ClosedPublic

Authored by mkazantsev on Sep 19 2022, 3:22 AM.

Details

Summary

This bug was found by recent improvement in SCEV verifier. The code in LoopFuse
directly reassigns blocks to be a part of a different loop, which should automatically
invalidate all related cached loop dispositions.

Diff Detail

Event Timeline

mkazantsev created this revision.Sep 19 2022, 3:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2022, 3:22 AM
mkazantsev requested review of this revision.Sep 19 2022, 3:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2022, 3:22 AM

Keeping drop of these loop dispositions as a separate call generally looks increasingly annoying... I'll see if there is a way to get rid of it.

nikic accepted this revision.Sep 19 2022, 3:26 AM

LGTM

This revision is now accepted and ready to land.Sep 19 2022, 3:26 AM
fhahn added a comment.Sep 19 2022, 3:30 AM

Keeping drop of these loop dispositions as a separate call generally looks increasingly annoying... I'll see if there is a way to get rid of it.

Hmm, would it make sense to forget loop dispositions as part of forgetLoop? Having to clean them up separately is very easy to forget and also not really clear from the existing documentation.

Keeping drop of these loop dispositions as a separate call generally looks increasingly annoying... I'll see if there is a way to get rid of it.

Hmm, would it make sense to forget loop dispositions as part of forgetLoop? Having to clean them up separately is very easy to forget and also not really clear from the existing documentation.

I'd be fine with that, but depends on CT. Let's extinguish fire and try to measure it.

nikic added a comment.Sep 19 2022, 3:44 AM

Keeping drop of these loop dispositions as a separate call generally looks increasingly annoying... I'll see if there is a way to get rid of it.

Hmm, would it make sense to forget loop dispositions as part of forgetLoop? Having to clean them up separately is very easy to forget and also not really clear from the existing documentation.

forgetLoop() already clears loop dispositions for values it forgets -- but these are only the values based on loop header phis, so an explicit forgetLoopDispositions() is needed if the disposition of other values changes.

We can't easily clear all dispositions for a loop because of how these maps are indexed -- we can either efficiently clear dispositions for a SCEV or for a Loop, but not both at the same time. This is a recurring problem in SCEV, I wonder if it has some elegant solution. (We basically need a multi-key map where each key part can be efficiently invalidated.)

This revision was landed with ongoing or failed builds.Sep 19 2022, 3:49 AM
This revision was automatically updated to reflect the committed changes.

But we could have a second parallel index, and whenever we cache SCEV-> loop also remember loop->SCEV mapping in other place. Doesn't really sound too complex.