This is an archive of the discontinued LLVM Phabricator instance.

SCEV should forget all loops containing a deleted block.
ClosedPublic

Authored by asbirlea on Aug 7 2018, 5:10 PM.

Details

Summary

LoopSimplifyCFG should update ScEv for all loops after a block is deleted.
If the deleted block "Succ" is part of L, then it is part of all parent loops, so forget all parent loops as well.

Diff Detail

Repository
rL LLVM

Event Timeline

asbirlea created this revision.Aug 7 2018, 5:10 PM

Is there a test for this?

asbirlea updated this revision to Diff 159747.Aug 8 2018, 9:53 AM

Updated to invalidate topmost loop.
Added test, courtesy of Mikael Holmén.

mkazantsev accepted this revision.Aug 8 2018, 8:07 PM

LGTM

test/Transforms/LoopIdiom/scev-invalidation_topmostloop.ll
5 ↗(On Diff #159747)

Please add | FileCheck %s to command line and smth like CHECK: @f1 in the test itself.

This revision is now accepted and ready to land.Aug 8 2018, 8:07 PM

Thanks for fixing this asbirlea!

greened added inline comments.Aug 9 2018, 10:41 AM
test/Transforms/LoopIdiom/scev-invalidation_topmostloop.ll
5 ↗(On Diff #159747)

Is this actually testing the functionality of this change? I'm wondering how this problem was discovered. If it was a miscompilation, we should have a test that ensures we don't reintroduce the problem. If it was discovered by inspection,. then I'm guessing constructing a proper test would be difficult. I asked about a test not as a demand to produce one but rather to try to see if we have an actual observed problem we could capture in a test. If we don't I'm not sure constructing a test that doesn't actually test anything is useful.

asbirlea marked 2 inline comments as done.Aug 9 2018, 10:49 AM
asbirlea added inline comments.
test/Transforms/LoopIdiom/scev-invalidation_topmostloop.ll
5 ↗(On Diff #159747)

The test triggers an assert without this fix, so it fails without needing any kind of CHECK. The issue was discovered by Mikael who also provided the failing test.
The added FileCheck that Maxim suggested is just a basic sanity, not really needed but it won't hurt either. Adding shortly and checking in.

asbirlea updated this revision to Diff 159956.Aug 9 2018, 10:51 AM
asbirlea marked an inline comment as done.

Address comment.

This revision was automatically updated to reflect the committed changes.