This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Do not split blocks if breaking a loop
Needs ReviewPublic

Authored by junbuml on Feb 24 2017, 9:32 AM.

Details

Summary

Do not insert a new block, if it could transform a loop into an irreducible loop.

Diff Detail

Event Timeline

junbuml created this revision.Feb 24 2017, 9:32 AM
junbuml added a subscriber: llvm-commits.

Kindly ping. Please let me know any comment.

Another option here would be to make SimplifyCFG insert a preheader for loops which don't have one. That seems better in terms of canonicalization.

Err, nevermind... I somehow thought we were preserving preheaders already in SimplifyCFG, but I guess we aren't.

I'll think about this a bit more.

Added some code review comments.

At a higher level, we should consider changing SimplifyCFG so it doesn't fight LoopSimplify over the canonical form of a loop... but just fixing the bug is fine for now.

lib/Transforms/Utils/SimplifyCFG.cpp
172

Do we need to do any additional work to keep this map up-to-date? The predecessors of the loop header could get folded.

1800

BBEnd instead of BI1->getSuccessor(0)?

1802

*irreducible

mcrosier resigned from this revision.Jul 26 2017, 6:08 AM
sanjoy resigned from this revision.Jan 29 2022, 5:34 PM