[PATCH] [PR18861] Fix for LoopUnroll pass was breaking LCSSA form while completely removing loop

Andrew Trick atrick at apple.com
Tue May 27 18:10:19 PDT 2014


Hi Dinesh,

This looks like it will work. It is different than the fix I was proposing and very tricky. I actually thought your fix was incorrect before realizing you're checking the Latch's ParentLoop after calling deleteLoopFromQueue. This ensures that the final loop latch will already be promoted to the outermost loop that any loop exit branches to. Note that we only care about the last loop latch (std::prev(Latches.end())), so I don't think you need to check all latches. If you add comments something like this then it's good to commit:

LCSSA must be performed on the outermost affected loop. The unrolled
loop's last loop latch is guaranteed to be in the outermost loop after
deleteLoopFromQueue updates LoopInfo.

Then you could either add this comment:

This may conservatively run LCSSA on the parent loop one level higher in the loop tree than necessary.

Or you could optimize the code further by keeping track of the loop one level below OuterL and calling formLCSSA on that intstead.

http://reviews.llvm.org/D2976






More information about the llvm-commits mailing list