[PATCH] D43256: [MBP] Move a latch block with conditional exit and multi predecessors to top of loop
Gal Zohar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 7 13:15:11 PST 2021
GalZohar added a comment.
In D43256#2480636 <https://reviews.llvm.org/D43256#2480636>, @Carrot wrote:
> @GalZohar, the various layout algorithms in MachineBlockPlacement mainly consider the number of fall-throughs and dynamic number of branch instructions (usually they are consistent) according to branch probabilities. So you can try to build your application with profiling. Or you can compile this file with -Os since the improvement in this patch is disabled with -Os.
In the simple example I have the number of branches executed when running the most common control flow path is increased by 1 due to this transformation.
Seems like in nested loops, where the outer-loop latch is moved to fall through into the outer-loop head, then the inner loop needs an additional exit branch, which increases the number of dynamic branches by 1 for every outer-loop iteration that also executes the inner loop. Is this intentional?
Disabling this completely degrades performance in some more complex examples where the total number of branches is not increased and therefore this optimization is beneficial. I would prefer to keep this when the number of branches isn't increased but skip it otherwise, like the nested loop example above.
I'm not sure how profiling would help my situation, as it seems like the number of branches may be increased regardless of block frequency values, as there's 1 path that executes an extra branch instruction.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D43256/new/
https://reviews.llvm.org/D43256
More information about the llvm-commits
mailing list