[llvm] [LoopRotate] Set loop back edge weight to not less than exit weight (PR #86496)

Haohai Wen via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 27 23:46:34 PDT 2024


HaohaiWen wrote:




> Actually I'm a bit confused looking at the test case..
> 
> 1. You can have zero-trip loop, in which case `loop_exit` can be reached without going into `loop_body`, why loop back edge needs to be not less than exit weight?

Entering line 351 means HasConditionalPreHeader is false. That means this loop body must be executed at least once. Each execution of loop body must have a back edge to latch. Then it either go back to loop body or exit.


> 2. In principle, profile inference for sample PGO should make input counts consistent. If there's input count inconsistency, we need track down the source of inconsistency. Fixing the input count inconsistency in a transformation isn't the right approach IMO. (The existing heuristic are making guesses for loop rotation which is different and is fine)

Ideally, It should be fixed when loading profile in SampleProfileLoader. For this case, unless SampleProfilerLoader detecting the loop body must be executed at least (I think it's not easy for SampleProfileLoader), it have no idea whether this profile data is good.


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


More information about the llvm-commits mailing list