Skip to content

Commit cd963f1

Browse files
authored
Merge branch 'main' into issue_169304
2 parents 4e53bd0 + 50916a4 commit cd963f1

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,9 +1007,8 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
10071007

10081008
switch (getOpcode()) {
10091009
case Instruction::Select: {
1010-
// TODO: It may be possible to improve this by analyzing where the
1011-
// condition operand comes from.
1012-
CmpInst::Predicate Pred = CmpInst::BAD_ICMP_PREDICATE;
1010+
llvm::CmpPredicate Pred = CmpInst::BAD_ICMP_PREDICATE;
1011+
match(getOperand(0), m_Cmp(Pred, m_VPValue(), m_VPValue()));
10131012
auto *CondTy = Ctx.Types.inferScalarType(getOperand(0));
10141013
auto *VecTy = Ctx.Types.inferScalarType(getOperand(1));
10151014
if (!vputils::onlyFirstLaneUsed(this)) {

llvm/test/Transforms/LoopVectorize/AArch64/select-costs.ll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,26 @@ exit:
7373
%1 = select i1 %all.off, i32 1, i32 %0
7474
ret i32 %1
7575
}
76+
77+
define i32 @select_vpinst_for_tail_folding(i8 %n) {
78+
; CHECK: LV: Checking a loop in 'select_vpinst_for_tail_folding'
79+
; CHECK: Cost of 1 for VF 2: EMIT vp<{{.+}}> = select vp<{{.+}}>, ir<%red.next>, ir<%red>
80+
; CHECK: Cost of 1 for VF 4: EMIT vp<{{.+}}> = select vp<{{.+}}>, ir<%red.next>, ir<%red>
81+
; CHECK: LV: Selecting VF: 4
82+
83+
entry:
84+
%c = icmp ne i8 %n, 0
85+
%ext = zext i1 %c to i32
86+
br label %loop
87+
88+
loop:
89+
%iv = phi i32 [ %ext, %entry ], [ %iv.next, %loop ]
90+
%red = phi i32 [ 0, %entry ], [ %red.next, %loop ]
91+
%iv.next = add i32 %iv, 1
92+
%red.next = mul i32 %red, %iv
93+
%ec = icmp eq i32 %iv, 12
94+
br i1 %ec, label %exit, label %loop
95+
96+
exit:
97+
ret i32 %red.next
98+
}

0 commit comments

Comments
 (0)