This is an archive of the discontinued LLVM Phabricator instance.

[LoopFlatten] Fix IV increment use count
ClosedPublic

Authored by dmgreen on Nov 21 2022, 12:39 AM.

Details

Summary

The add from the IV in the inner loop was always checking for 2 uses, the phi and the compare. The compare could be based on the phi though, leaving one valid use of the compare. In the testcase we could be left with the phi and a lcssa phi as the two users, invalidly allowing flattening where we shouldn't.

Fixes 58441

Diff Detail

Event Timeline

dmgreen created this revision.Nov 21 2022, 12:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 12:39 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
dmgreen requested review of this revision.Nov 21 2022, 12:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 12:39 AM
SjoerdMeijer accepted this revision.Nov 21 2022, 1:56 AM

I had a look, but you got there first! Thanks for fixing!

This was reported after enabling LoopFlatten by default. I will wait a couple of days to see if there's no fall out from this change, then I will try flipping the switch again later this week.

This revision is now accepted and ready to land.Nov 21 2022, 1:56 AM

Thanks - that sounds good to me.

This revision was automatically updated to reflect the committed changes.