[llvm] [LV][VPlan] Implement VPlan-based cost for exit condition. (PR #125640)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 28 17:47:00 PST 2025


ElvisWang123 wrote:

Rebased to latest and ping!

Summary reasons of VF decrease for different benchmarks in the latest commit.

| benchmark  | reason  |
|---|---|
| AArch64/conditional-branches-cost.ll | Before the patch, the cost of the icmp only count once through `exit-condition`, but it will actually contains two costs. `icmp` in `pred.if` and a `branchOnCount` at the end of the vector region. | 
| X86/constant-fold.ll | Max TC = 3 make VF 2, 4 still need scalar epilogue which is not profitable. |
| X86/multi-exit-cost.l  | TC = 31, this make VF = 16 needs 15 iteration of scalar epilogue which is expensive.|
| X86/optsize.ll  | Optimize for code size |
| X86/pr81872.ll | TC = 9 |
| X86/predicate-switch.ll | Since this patch try to support cost of `fcmp/icmp` the loop won't be vectorized because there exits two `icmp`in the middle of the loop and the cost now accounted. |
| X86/scev-checks-unprofitable.ll | TC = 7 |

Possible solutions.

-  If the test is created for some optimization or functional coverage. It's probably better to force vectorize or setting the vector-width to make sure the test always be vectorized.
- Increase the small ( not power-of-2 friendly) trip count to large trip count to make if more friendly to choose large VF.

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


More information about the llvm-commits mailing list