I don't really know this area of LLVM, and probably not equipped to drive this the end.
This is motivated by D113342, but implemented in a more general manner.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Analysis/BranchProbabilityInfo.cpp | ||
---|---|---|
850 | Please correct me if I understand the idea incorrectly. |
It seems that the new heuristic is applied not only to loops in rotated form. For example "test_cold_loop" or "test13".
In general we should decrease probability to take particular back edge proportionally to number of added exits. For example if number of exits equal to number of predicted iterations then each particular exit should be 50/50. But this is not supported yet anyway..
llvm/lib/Analysis/BranchProbabilityInfo.cpp | ||
---|---|---|
851 | IMHO isRotatedForm check is not enough because it only checks "form". For example, a user written do-while loop under some irrelevant guard condition. Is it possible to also check if we are checking on induction variable of SuccLoop? I guess this covers most cases with minimum false positive. |
Please correct me if I understand the idea incorrectly.
The problem at this point is that we don't know if the entering edge is duplicated from loop exit branch from LoopRotate. The edge could be from source code or other transformations, in this case, we don't really know the probability taking or skipping the guarded loop. For example, GCC has a heuristics saying that guarded inner loop in loop nest usually is not likely to be executed.