Skip to content

Commit b0c8a84

Browse files
committed
Address review comments
1 parent 8ed000d commit b0c8a84

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,9 @@ Value *VPInstruction::generate(VPTransformState &State) {
469469
return Builder.CreateNot(A, Name);
470470
}
471471
case Instruction::ExtractElement: {
472+
assert(State.VF.isVector() && "Only extract elements from vectors");
472473
Value *Vec = State.get(getOperand(0));
473-
Value *Idx = State.get(getOperand(1), true);
474+
Value *Idx = State.get(getOperand(1), /*IsScalar=*/true);
474475
return Builder.CreateExtractElement(Vec, Idx, Name);
475476
}
476477
case Instruction::ICmp: {
@@ -887,6 +888,8 @@ bool VPInstruction::onlyFirstLaneUsed(const VPValue *Op) const {
887888
return false;
888889
case Instruction::PHI:
889890
return true;
891+
case Instruction::ExtractElement:
892+
return Op == getOperand(1);
890893
case Instruction::ICmp:
891894
case Instruction::Select:
892895
case Instruction::Or:

llvm/test/Transforms/LoopVectorize/AArch64/early_exit_costs.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ define i64 @same_exit_block_pre_inc_use1_sve() #1 {
1414
; CHECK-NEXT: Cost of 4 for VF vscale x 16: EMIT vp<{{.*}}> = first-active-lane vp<{{.*}}>
1515
; CHECK-NEXT: Cost of 2 for VF vscale x 16: EMIT vp<{{.*}}> = extractelement ir<{{.*}}>, vp<{{.*}}>
1616
; CHECK-NEXT: Cost of 4 for VF vscale x 16: EMIT vp<{{.*}}>.1 = first-active-lane vp<{{.*}}>
17-
; CHECK-NEXT: Cost of 2 for VF vscale x 16: EMIT vp<{{.*}}>.1 = extractelement ir<{{.*}}>, vp<%first.active.lane>.1
17+
; CHECK-NEXT: Cost of 2 for VF vscale x 16: EMIT vp<{{.*}}>.1 = extractelement ir<{{.*}}>, vp<{{.*}}>.1
1818
; CHECK: LV: Minimum required TC for runtime checks to be profitable:32
1919
entry:
2020
%p1 = alloca [1024 x i8]
@@ -53,7 +53,7 @@ define i64 @same_exit_block_pre_inc_use1_nosve() {
5353
; CHECK-NEXT: Cost of 48 for VF 16: EMIT vp<{{.*}}> = first-active-lane vp<{{.*}}>
5454
; CHECK-NEXT: Cost of 2 for VF 16: EMIT vp<{{.*}}> = extractelement ir<{{.*}}>, vp<{{.*}}>
5555
; CHECK-NEXT: Cost of 48 for VF 16: EMIT vp<{{.*}}>.1 = first-active-lane vp<{{.*}}>
56-
; CHECK-NEXT: Cost of 2 for VF 16: EMIT vp<{{.*}}>.1 = extractelement ir<{{.*}}>, vp<%first.active.lane>.1
56+
; CHECK-NEXT: Cost of 2 for VF 16: EMIT vp<{{.*}}>.1 = extractelement ir<{{.*}}>, vp<{{.*}}>.1
5757
; CHECK: LV: Minimum required TC for runtime checks to be profitable:176
5858
; CHECK-NEXT: LV: Vectorization is not beneficial: expected trip count < minimum profitable VF (64 < 176)
5959
; CHECK-NEXT: LV: Too many memory checks needed.

0 commit comments

Comments
 (0)