This is an archive of the discontinued LLVM Phabricator instance.

[LoopFlatten] Loop limit invariant checks
Needs RevisionPublic

Authored by SjoerdMeijer on Oct 14 2020, 2:34 AM.

Details

Summary

If the loop limit is not invariant don't directly bail out, but try to make it invariant with makeLoopInvariant.
I precommitted the test case for this in rG20c7ab87a78c.

Diff Detail

Event Timeline

SjoerdMeijer created this revision.Oct 14 2020, 2:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2020, 2:34 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
SjoerdMeijer requested review of this revision.Oct 14 2020, 2:34 AM
dmgreen added inline comments.Oct 16 2020, 12:20 AM
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
439

All these return false now need to return Changed, I think.

llvm/test/Transforms/LoopFlatten/limit-not-invariant.ll
14

These tests don't then flatten?

SjoerdMeijer added inline comments.Oct 20 2020, 7:37 AM
llvm/test/Transforms/LoopFlatten/limit-not-invariant.ll
14

Well spotted. This patch was part of my grand master plan to support different phi types, and this patch was to get the first little obstacle out of the way. But because of changes in D88880, the input IR and test case might not be so relevant anymore, so I will look at that first now because I still think this is little change is useful.

fhahn requested changes to this revision.Mar 10 2021, 12:16 PM

(marking as changes requested to clear up review queue as there are outstanding comments)

llvm/lib/Transforms/Scalar/LoopFlatten.cpp
431

Update the comment saying we try to make it invariant?

432

does this need to be initialized? I think there might be some code paths in makeLoopInvariant that do not set Changed.

This revision now requires changes to proceed.Mar 10 2021, 12:16 PM