Skip to content

Commit 95e38ba

Browse files
authored
[RISCV] Enable prefetching writes (#130561)
We should prefetch writes since `Zicbop` has `prefetch.w`.
1 parent 612e4e9 commit 95e38ba

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/Target/RISCV/RISCVSubtarget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
354354
unsigned getMaxPrefetchIterationsAhead() const override {
355355
return TuneInfo->MaxPrefetchIterationsAhead;
356356
};
357+
bool enableWritePrefetching() const override { return true; }
357358

358359
unsigned getMinimumJumpTableEntries() const;
359360

llvm/test/Transforms/LoopDataPrefetch/RISCV/basic.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ define void @foo(ptr nocapture %a, ptr nocapture readonly %b) {
1111
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
1212
; CHECK-NEXT: [[TMP0:%.*]] = shl nuw nsw i64 [[INDVARS_IV]], 3
1313
; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[TMP0]], 64
14-
; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[B]], i64 [[TMP1]]
14+
; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[A]], i64 [[TMP1]]
15+
; CHECK-NEXT: [[TMP4:%.*]] = shl nuw nsw i64 [[INDVARS_IV]], 3
16+
; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[TMP4]], 64
17+
; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[B]], i64 [[TMP3]]
1518
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds double, ptr [[B]], i64 [[INDVARS_IV]]
1619
; CHECK-NEXT: call void @llvm.prefetch.p0(ptr [[SCEVGEP]], i32 0, i32 3, i32 1)
1720
; CHECK-NEXT: [[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8
1821
; CHECK-NEXT: [[ADD:%.*]] = fadd double [[TMP2]], 1.000000e+00
1922
; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds double, ptr [[A]], i64 [[INDVARS_IV]]
23+
; CHECK-NEXT: call void @llvm.prefetch.p0(ptr [[SCEVGEP1]], i32 1, i32 3, i32 1)
2024
; CHECK-NEXT: store double [[ADD]], ptr [[ARRAYIDX2]], align 8
2125
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
2226
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 1600

0 commit comments

Comments
 (0)