Skip to content

Commit ea3c380

Browse files
committed
[LV] Use ICMP_UGE for BranchOnCount when VF is scalable
So that SCEV can analyse the bound of loop count. This can fix issue found in llvm#100564.
1 parent 8410bab commit ea3c380

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,10 @@ Value *VPInstruction::generatePerPart(VPTransformState &State, unsigned Part) {
524524
// First create the compare.
525525
Value *IV = State.get(getOperand(0), Part, /*IsScalar*/ true);
526526
Value *TC = State.get(getOperand(1), Part, /*IsScalar*/ true);
527-
Value *Cond = Builder.CreateICmpEQ(IV, TC);
527+
// Use ICMP_UGE so that SCEV can analyse the bound of loop count for
528+
// scalable VF.
529+
Value *Cond = Builder.CreateICmp(
530+
State.VF.isScalable() ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_EQ, IV, TC);
528531

529532
// Now create the branch.
530533
auto *Plan = getParent()->getPlan();

0 commit comments

Comments
 (0)