Skip to content

Commit a04c6b5

Browse files
authored
[LV] Update LoopVectorizationPlanner::emitInvalidCostRemarks to handle reduction plans (#165913)
The TypeSwitch for extracting the Opcode now handles the `VPReductionRecipe` case. Fixes #165359.
1 parent 6a0ba8b commit a04c6b5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,6 +4018,9 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
40184018
.Case<VPInterleaveRecipe>([](const VPInterleaveRecipe *R) {
40194019
return R->getStoredValues().empty() ? Instruction::Load
40204020
: Instruction::Store;
4021+
})
4022+
.Case<VPReductionRecipe>([](const auto *R) {
4023+
return RecurrenceDescriptor::getOpcode(R->getRecurrenceKind());
40214024
});
40224025

40234026
// If the next recipe is different, or if there are no other pairs,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; RUN: opt < %s -passes=loop-vectorize -S -pass-remarks-analysis=loop-vectorize -disable-output &> %t
2+
; RUN: cat %t | FileCheck --check-prefix=CHECK-REMARKS %s
3+
4+
; CHECK-REMARKS: remark: <unknown>:0:0: Recipe with invalid costs prevented vectorization at VF=(vscale x 1): fadd
5+
6+
target triple = "aarch64-unknown-linux-gnu"
7+
8+
define double @reduce_fail(i64 %loop_count, double %d0, ptr %ptr1) #0 {
9+
entry:
10+
%d1 = load double, ptr %ptr1
11+
br label %loop
12+
13+
loop:
14+
%acc0 = phi double [ %fadd0, %loop ], [ %d0, %entry ]
15+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
16+
%fadd0 = fadd double %acc0, %d1
17+
%iv.next = add nsw nuw i64 %iv, 1
18+
%exit_cond = icmp eq i64 %iv.next, %loop_count
19+
br i1 %exit_cond, label %loopexit, label %loop
20+
21+
loopexit:
22+
ret double %fadd0
23+
}
24+
25+
attributes #0 = { "target-features"="+sve" }

0 commit comments

Comments
 (0)