[all-commits] [llvm/llvm-project] 2d31b0: Compute estimated trip counts for multiple exit loops
Philip Reames via All-commits
all-commits at lists.llvm.org
Thu Dec 9 09:54:05 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2d31b02517c0eacfa7edf62822cb7265e804e89c
https://github.com/llvm/llvm-project/commit/2d31b02517c0eacfa7edf62822cb7265e804e89c
Author: Philip Reames <listmail at philipreames.com>
Date: 2021-12-09 (Thu, 09 Dec 2021)
Changed paths:
M llvm/lib/Transforms/Utils/LoopPeel.cpp
M llvm/lib/Transforms/Utils/LoopUtils.cpp
M llvm/test/Transforms/LoopUnroll/runtime-multiexit-heuristic.ll
Log Message:
-----------
Compute estimated trip counts for multiple exit loops
This change allows us to estimate trip count from profile metadata for all multiple exit loops. We still do the estimate only from the latch, but that's fine as it causes us to over estimate the trip count at worst.
Reviewing the uses of the API, all but one are cases where we restrict a loop transformation (unroll, and vectorize respectively) when we know the trip count is short enough. So, as a result, the change makes these passes strictly less aggressive. The test change illustrates a case where we'd previously have runtime unrolled a loop which ran fewer iterations than the unroll factor. This is definitely unprofitable.
The one case where an upper bound on estimate trip count could drive a more aggressive transform is peeling, and I duplicated the logic being removed from the generic estimation there to keep it the same. The resulting heuristic makes no sense and should probably be immediately removed, but we can do that in a separate change.
This was noticed when analyzing regressions on D113939.
I plan to come back and incorporate estimated trip counts from other exits, but that's a minor improvement which can follow separately.
Differential Revision: https://reviews.llvm.org/D115362
More information about the All-commits
mailing list