Skip to content

Commit e8177b2

Browse files
committed
Updated the comments and testcase updated.
1 parent 16e7516 commit e8177b2

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ bool RISCVRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
573573
int64_t Val = Offset.getFixed();
574574
int64_t Lo12 = SignExtend64<12>(Val);
575575
unsigned Opc = MI.getOpcode();
576-
int64_t Imm9Val = SignExtend64<9>(Val);
577576
auto &Subtarget = MF.getSubtarget<RISCVSubtarget>();
578577

579578
if (Opc == RISCV::ADDI && !isInt<12>(Val)) {
@@ -588,9 +587,8 @@ bool RISCVRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
588587
(Lo12 & 0b11111) != 0) {
589588
// Prefetch instructions require the offset to be 32 byte aligned.
590589
MI.getOperand(FIOperandNum + 1).ChangeToImmediate(0);
591-
} else if ((Opc == RISCV::PREFETCH_I || Opc == RISCV::PREFETCH_R ||
592-
Opc == RISCV::PREFETCH_W) &&
593-
Subtarget.hasVendorXMIPSCBOP() && !isUInt<9>(Imm9Val)) {
590+
} else if (Opc == RISCV::MIPS_PREFETCH && Subtarget.hasVendorXMIPSCBOP() &&
591+
!isUInt<9>(Val)) {
594592
// MIPS Prefetch instructions require the offset to be 9 bits encoded.
595593
MI.getOperand(FIOperandNum + 1).ChangeToImmediate(0);
596594
} else if ((Opc == RISCV::PseudoRV32ZdinxLD ||

llvm/test/CodeGen/RISCV/xmips-cbop.ll

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,30 @@ define void @prefetch_inst_read(ptr noundef %ptr) nounwind {
5353
define void @prefetch_frameindex_test_neg() nounwind {
5454
; RV32XMIPSPREFETCH-LABEL: prefetch_frameindex_test_neg:
5555
; RV32XMIPSPREFETCH: # %bb.0:
56-
; RV32XMIPSPREFETCH-NEXT: addi sp, sp, -512
57-
; RV32XMIPSPREFETCH-NEXT: addi a0, sp, -32
56+
; RV32XMIPSPREFETCH-NEXT: lui a0, 1
57+
; RV32XMIPSPREFETCH-NEXT: addi a0, a0, 16
58+
; RV32XMIPSPREFETCH-NEXT: sub sp, sp, a0
59+
; RV32XMIPSPREFETCH-NEXT: addi a0, sp, 524
5860
; RV32XMIPSPREFETCH-NEXT: mips.pref 8, 0(a0)
59-
; RV32XMIPSPREFETCH-NEXT: addi sp, sp, 512
61+
; RV32XMIPSPREFETCH-NEXT: lui a0, 1
62+
; RV32XMIPSPREFETCH-NEXT: addi a0, a0, 16
63+
; RV32XMIPSPREFETCH-NEXT: add sp, sp, a0
6064
; RV32XMIPSPREFETCH-NEXT: ret
6165
;
6266
; RV64XMIPSPREFETCH-LABEL: prefetch_frameindex_test_neg:
6367
; RV64XMIPSPREFETCH: # %bb.0:
64-
; RV64XMIPSPREFETCH-NEXT: addi sp, sp, -512
65-
; RV64XMIPSPREFETCH-NEXT: addi a0, sp, -32
68+
; RV64XMIPSPREFETCH-NEXT: lui a0, 1
69+
; RV64XMIPSPREFETCH-NEXT: addi a0, a0, 16
70+
; RV64XMIPSPREFETCH-NEXT: sub sp, sp, a0
71+
; RV64XMIPSPREFETCH-NEXT: addi a0, sp, 524
6672
; RV64XMIPSPREFETCH-NEXT: mips.pref 8, 0(a0)
67-
; RV64XMIPSPREFETCH-NEXT: addi sp, sp, 512
73+
; RV64XMIPSPREFETCH-NEXT: lui a0, 1
74+
; RV64XMIPSPREFETCH-NEXT: addi a0, a0, 16
75+
; RV64XMIPSPREFETCH-NEXT: add sp, sp, a0
6876
; RV64XMIPSPREFETCH-NEXT: ret
69-
%data = alloca [128 x i32], align 4
77+
%data = alloca [1024 x i32], align 4
7078
%base = bitcast ptr %data to ptr
71-
%ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 -8
79+
%ptr = getelementptr [127 x i32], ptr %base, i32 0, i32 127
7280
call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)
7381
ret void
7482
}
@@ -87,7 +95,7 @@ define void @prefetch_frameindex_test() nounwind {
8795
; RV64XMIPSPREFETCH-NEXT: mips.pref 8, 32(sp)
8896
; RV64XMIPSPREFETCH-NEXT: addi sp, sp, 512
8997
; RV64XMIPSPREFETCH-NEXT: ret
90-
%data = alloca [128 x i32], align 4
98+
%data = alloca [128 x i32], align 4
9199
%base = bitcast ptr %data to ptr
92100
%ptr = getelementptr [128 x i32], ptr %base, i32 0, i32 8
93101
call void @llvm.prefetch(ptr %ptr, i32 0, i32 0, i32 1)

0 commit comments

Comments
 (0)