In https://reviews.llvm.org/D60606#1464782 Philip Reames pointed out that partial unswitched branches lose their profile information.
This patch fixes SimpleLoopUnswitch pass to make it happen: to not reuse the stale perf branch_weights if any but explicitly discard them for partially unswitched branches.
Couple of tests are fixed to check the changes both for trivial and non-trivial unswitch.
Details
- Reviewers
reames asbirlea mkazantsev chandlerc
Diff Detail
Event Timeline
The change description and your tests make it hard to determine what your intended result is. Please fix.
Please update your change description to explain *why* stripping metadata is the best answer. A small example might help. Or alternatively, turn the small examples into (new) test cases and reference them from the proposed commit message.
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | ||
---|---|---|
490 | I believe the same problem exists for full unswitch as well, and thus this change should not be conditional. As an example, consider: if (A) break if (B) break; } Where we're unswitching B, but not A for some reason. The frequency on the new B branch could be quite different depending on whether A and B are correlated. | |
2013 | I'd suggest moving this to right after the branch successor rewriting. Also, there is a bug here if this function is called w/BI null and SI non null. | |
llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll | ||
2703 | Please separate and commit your test changes, then rebase over them. At the moment, I can't actually tell what's changing vs what are changes to the tests. note that you should make sure to have tests both with and without profile weights. You don't need to (and should not) fully duplicate, but at least a few of each are required. |
I believe the same problem exists for full unswitch as well, and thus this change should not be conditional.
As an example, consider:
loop {
}
Where we're unswitching B, but not A for some reason. The frequency on the new B branch could be quite different depending on whether A and B are correlated.