[llvm] [VPlan] Untie tail folding from optimizeInductionLiveOutUsers. NFC (PR #207984)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 23 00:56:52 PDT 2026


================
@@ -826,7 +826,7 @@ define float @fmaxnum_constant_trip_count_tailfold(ptr %src) #0 {
 ; CHECK:       [[MIDDLE_BLOCK]]:
 ; CHECK-NEXT:    [[TMP30:%.*]] = select <4 x i1> [[TMP0]], <4 x float> [[TMP24]], <4 x float> [[VEC_PHI]]
 ; CHECK-NEXT:    [[TMP31:%.*]] = select i1 [[TMP27]], <4 x float> [[VEC_PHI]], <4 x float> [[TMP30]]
-; CHECK-NEXT:    [[TMP32:%.*]] = select i1 [[TMP27]], i64 [[INDEX]], i64 30
+; CHECK-NEXT:    [[TMP32:%.*]] = select i1 [[TMP27]], i64 [[INDEX]], i64 32
----------------
lukel97 wrote:

This arm of the select is actually dead, TMP32 is only used in the scalar loop IV, and we only branch to that when TMP27 is true, so the 30/32 is never read.

It's pretty confusing, and the existing code is relying on the select arm being dead for it to be correct, which is part of what this PR is trying to untangle. 

I.e. it's replacing the `m_ExitingIVValue` resume values in the scalar loop with the original trip count, which doesn't make much sense. The scalar loop should resume from the vector trip count, but it currently happens to work because that arm of the select is dead.

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


More information about the llvm-commits mailing list