[PATCH] D71578: [CodeMoverUtils] Improve IsControlFlowEquivalent.
Michael Kruse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 18 15:55:03 PST 2019
Meinersbur added a comment.
This is a quite deep introspection that I'd assume would be in the domain of some analysis, such as value numbering. It could ensure that equivalent conditional branches will take the same `llvm::Value`.
However, if your use case is loop fusion, then it might not even be necessary. Loop fusion can be made strictly more powerful by sinking the loop condition into the loop. Another pass might then be able to optimize the fused interior if the conditions are equivalent. That is,
if (c1)
for (int i = 0; i < n; ++i)
body1(i);
if (c2)
for (int i = 0; i < n; ++i)
body2(i);
can be fused to
for (int i = 0; i < n; ++i) {
if (c1)
body1(i);
if (c2)
body2(i);
}
If `c1` is equivalent to `c2`, JumpThreading may change it to
for (int i = 0; i < n; ++i) {
if (c1) {
body1(i);
body2(i);
}
}
Hoisting `c1` out of the loop again, even if `c1` and `c2` stay separate would be a job for LoopUnswitching.
I realize (well, I did not in the call this morning) that fusing that loop fusion will probably not improve performance unless `c1` and `c2` usually evaluate to `true`, but at least for correctness (#pragma clang loop fuse), it is valid. Profitability can be checked separately.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71578/new/
https://reviews.llvm.org/D71578
More information about the llvm-commits
mailing list