[llvm-branch-commits] [llvm] 09b884a - [VPlan] Use VPlan::hasTailFolded in materializeConstantVectorTC. (#209502)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jul 23 23:06:36 PDT 2026
Author: Florian Hahn
Date: 2026-07-24T08:06:26+02:00
New Revision: 09b884a41dab18f4bb933e999d7923970698aed1
URL: https://github.com/llvm/llvm-project/commit/09b884a41dab18f4bb933e999d7923970698aed1
DIFF: https://github.com/llvm/llvm-project/commit/09b884a41dab18f4bb933e999d7923970698aed1.diff
LOG: [VPlan] Use VPlan::hasTailFolded in materializeConstantVectorTC. (#209502)
The current checks in materializeConstantVectorTripCount miss
tail-folded cases when vectorizing loops with fmax without fast-math
flags. Use recently added hasTailFolded helper to ensure we always bail
out on tail-folded loops.
Fixes https://github.com/llvm/llvm-project/issues/209159.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
llvm/test/Transforms/LoopVectorize/fmax-without-fast-math-flags.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index f37d61f8464fa..b0e5a5c4449b8 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -5451,7 +5451,7 @@ void VPlanTransforms::materializeConstantVectorTripCount(
// Skip cases for which the trip count may be non-trivial to materialize.
// I.e., when a scalar tail is absent - due to tail folding, or when a scalar
// tail is required.
- if (!Plan.hasScalarTail() ||
+ if (Plan.hasTailFolded() || !Plan.hasScalarTail() ||
Plan.getMiddleBlock()->getSingleSuccessor() ==
Plan.getScalarPreheader() ||
!isa<VPIRValue>(TC))
diff --git a/llvm/test/Transforms/LoopVectorize/fmax-without-fast-math-flags.ll b/llvm/test/Transforms/LoopVectorize/fmax-without-fast-math-flags.ll
index ef01bb29c1589..e04caf61609f4 100644
--- a/llvm/test/Transforms/LoopVectorize/fmax-without-fast-math-flags.ll
+++ b/llvm/test/Transforms/LoopVectorize/fmax-without-fast-math-flags.ll
@@ -819,7 +819,7 @@ define float @fmaxnum_constant_trip_count_tailfold(ptr %src) #0 {
; CHECK-NEXT: [[TMP25:%.*]] = fcmp uno <4 x float> [[TMP23]], [[TMP23]]
; CHECK-NEXT: [[TMP26:%.*]] = freeze <4 x i1> [[TMP25]]
; CHECK-NEXT: [[TMP27:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP26]])
-; CHECK-NEXT: [[TMP28:%.*]] = icmp eq i64 [[INDEX_NEXT]], 28
+; CHECK-NEXT: [[TMP28:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32
; CHECK-NEXT: [[TMP29:%.*]] = or i1 [[TMP27]], [[TMP28]]
; CHECK-NEXT: [[VEC_IND_NEXT]] = add nuw <4 x i8> [[VEC_IND]], splat (i8 4)
; CHECK-NEXT: br i1 [[TMP29]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP12:![0-9]+]]
More information about the llvm-branch-commits
mailing list