[llvm] [CodeGen] Restore MachineBlockPlacement block ordering (PR #99351)

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 05:01:53 PDT 2024


john-brawn-arm wrote:

> when does it lead to worse performance? 

The added test is heavily reduced from a benchmark that got 7% worse when #91843 was committed. From looking at the -debug output it looks like what happens is:
 * We have a loop starting at bb.3 and ending at bb.35
 * bb.34 is tail-merged with bb.35, and the resulting block ends up being called bb.5 with successors bb.3 and bb.7, and bb.7 loops back to bb.3
 * In function order bb.5 is before bb.7, but in MachineLoopInfo order bb.5 is at the end of the function
 * Before #91843 (and with this PR) bb.5 is placed before bb.7 and falls through to it, so the bb.5->bb.7->bb.5 loop has a single backwards branch (from bb.7 to bb.5)
 * With #91843 bb.5 is placed at the end of the function, so the bb.5->bb.7->bb.5 loop has a forwards branch from bb.5 to bb.7 then a backwards branch from bb.7 to bb.5. 

> The underlying problem should probably be solved in a different way.

Perhaps. But I was hoping to do a simple fix that just restores the previous behaviour, given that #91843 was supposed to be a non-functional change.

https://github.com/llvm/llvm-project/pull/99351


More information about the llvm-commits mailing list