Skip to content

Commit 69fb40d

Browse files
nikolaypanchenkoAlexisPerry
authored andcommitted
[LV][NFC] Marked functions as const. Added LLVM_DEBUG. (llvm#96681)
1 parent 858e364 commit 69fb40d

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,29 +1431,40 @@ class LoopVectorizationCostModel {
14311431
/// Returns true if \p I is a memory instruction in an interleaved-group
14321432
/// of memory accesses that can be vectorized with wide vector loads/stores
14331433
/// and shuffles.
1434-
bool interleavedAccessCanBeWidened(Instruction *I, ElementCount VF);
1434+
bool interleavedAccessCanBeWidened(Instruction *I, ElementCount VF) const;
14351435

14361436
/// Check if \p Instr belongs to any interleaved access group.
1437-
bool isAccessInterleaved(Instruction *Instr) {
1437+
bool isAccessInterleaved(Instruction *Instr) const {
14381438
return InterleaveInfo.isInterleaved(Instr);
14391439
}
14401440

14411441
/// Get the interleaved access group that \p Instr belongs to.
14421442
const InterleaveGroup<Instruction> *
1443-
getInterleavedAccessGroup(Instruction *Instr) {
1443+
getInterleavedAccessGroup(Instruction *Instr) const {
14441444
return InterleaveInfo.getInterleaveGroup(Instr);
14451445
}
14461446

14471447
/// Returns true if we're required to use a scalar epilogue for at least
14481448
/// the final iteration of the original loop.
14491449
bool requiresScalarEpilogue(bool IsVectorizing) const {
1450-
if (!isScalarEpilogueAllowed())
1450+
if (!isScalarEpilogueAllowed()) {
1451+
LLVM_DEBUG(dbgs() << "LV: Loop does not require scalar epilogue\n");
14511452
return false;
1453+
}
14521454
// If we might exit from anywhere but the latch, must run the exiting
14531455
// iteration in scalar form.
1454-
if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch())
1456+
if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch()) {
1457+
LLVM_DEBUG(
1458+
dbgs() << "LV: Loop requires scalar epilogue: multiple exits\n");
1459+
return true;
1460+
}
1461+
if (IsVectorizing && InterleaveInfo.requiresScalarEpilogue()) {
1462+
LLVM_DEBUG(dbgs() << "LV: Loop requires scalar epilogue: "
1463+
"interleaved group requires scalar epilogue\n");
14551464
return true;
1456-
return IsVectorizing && InterleaveInfo.requiresScalarEpilogue();
1465+
}
1466+
LLVM_DEBUG(dbgs() << "LV: Loop does not require scalar epilogue\n");
1467+
return false;
14571468
}
14581469

14591470
/// Returns true if we're required to use a scalar epilogue for at least
@@ -3919,7 +3930,7 @@ LoopVectorizationCostModel::getDivRemSpeculationCost(Instruction *I,
39193930
}
39203931

39213932
bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
3922-
Instruction *I, ElementCount VF) {
3933+
Instruction *I, ElementCount VF) const {
39233934
assert(isAccessInterleaved(I) && "Expecting interleaved access.");
39243935
assert(getWideningDecision(I, VF) == CM_Unknown &&
39253936
"Decision should not be set yet.");

llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocaptur
5050
; CHECK-NEXT: LV: Scalarizing: %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %idxprom
5151
; CHECK-NEXT: LV: Scalarizing: %cmp = icmp ugt i64 %indvars.iv, 1
5252
; CHECK-NEXT: LV: Scalarizing: %indvars.iv.next = add nsw i64 %indvars.iv, -1
53+
; CHECK-NEXT: LV: Loop does not require scalar epilogue
54+
; CHECK-NEXT: LV: Loop does not require scalar epilogue
5355
; CHECK-NEXT: VPlan 'Initial VPlan for VF={vscale x 4},UF>=1' {
5456
; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
5557
; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
@@ -112,6 +114,7 @@ define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocaptur
112114
; CHECK-NEXT: LV(REG): RegisterClass: RISCV::GPRRC, 1 registers
113115
; CHECK-NEXT: LV: The target has 31 registers of RISCV::GPRRC register class
114116
; CHECK-NEXT: LV: The target has 32 registers of RISCV::VRRC register class
117+
; CHECK-NEXT: LV: Loop does not require scalar epilogue
115118
; CHECK-NEXT: LV: Loop cost is 32
116119
; CHECK-NEXT: LV: IC is 1
117120
; CHECK-NEXT: LV: VF is vscale x 4
@@ -121,6 +124,7 @@ define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocaptur
121124
; CHECK-NEXT: LEV: Epilogue vectorization is not profitable for this loop
122125
; CHECK-NEXT: Executing best plan with VF=vscale x 4, UF=1
123126
; CHECK: LV: Interleaving disabled by the pass manager
127+
; CHECK-NEXT: LV: Loop does not require scalar epilogue
124128
; CHECK-NEXT: LV: Vectorizing: innermost loop.
125129
; CHECK-EMPTY:
126130
;
@@ -191,6 +195,8 @@ define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocaptur
191195
; CHECK-NEXT: LV: Scalarizing: %arrayidx3 = getelementptr inbounds float, ptr %A, i64 %idxprom
192196
; CHECK-NEXT: LV: Scalarizing: %cmp = icmp ugt i64 %indvars.iv, 1
193197
; CHECK-NEXT: LV: Scalarizing: %indvars.iv.next = add nsw i64 %indvars.iv, -1
198+
; CHECK-NEXT: LV: Loop does not require scalar epilogue
199+
; CHECK-NEXT: LV: Loop does not require scalar epilogue
194200
; CHECK-NEXT: VPlan 'Initial VPlan for VF={vscale x 4},UF>=1' {
195201
; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
196202
; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
@@ -253,6 +259,7 @@ define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocaptur
253259
; CHECK-NEXT: LV(REG): RegisterClass: RISCV::GPRRC, 1 registers
254260
; CHECK-NEXT: LV: The target has 31 registers of RISCV::GPRRC register class
255261
; CHECK-NEXT: LV: The target has 32 registers of RISCV::VRRC register class
262+
; CHECK-NEXT: LV: Loop does not require scalar epilogue
256263
; CHECK-NEXT: LV: Loop cost is 32
257264
; CHECK-NEXT: LV: IC is 1
258265
; CHECK-NEXT: LV: VF is vscale x 4
@@ -262,6 +269,7 @@ define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocaptur
262269
; CHECK-NEXT: LEV: Epilogue vectorization is not profitable for this loop
263270
; CHECK-NEXT: Executing best plan with VF=vscale x 4, UF=1
264271
; CHECK: LV: Interleaving disabled by the pass manager
272+
; CHECK-NEXT: LV: Loop does not require scalar epilogue
265273
; CHECK-NEXT: LV: Vectorizing: innermost loop.
266274
;
267275
entry:

llvm/test/Transforms/LoopVectorize/vplan-printing-before-execute.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
88
; VF/IC combination.
99
define void @test_tc_less_than_16(ptr %A, i64 %N) {
1010
; CHECK: LV: Scalarizing: %cmp =
11-
; CHECK-NEXT: VPlan 'Initial VPlan for VF={8},UF>=1' {
11+
; CHECK: VPlan 'Initial VPlan for VF={8},UF>=1' {
1212
; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
1313
; CHECK-NEXT: Live-in vp<[[VTC:%.+]]> = vector-trip-count
1414
; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count

0 commit comments

Comments
 (0)