Skip to content

Commit 0cbdd2a

Browse files
committed
[RISCV] Fix isStoreToStackSlot
Because of the layout of stores (that don't have a destination operand) this check is exactly the same as the one in RISCVInstrInfo::isLoadFromStackSlot. Differential Revision: https://reviews.llvm.org/D81805
1 parent c1d021e commit 0cbdd2a

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ unsigned RISCVInstrInfo::isStoreToStackSlot(const MachineInstr &MI,
7676
break;
7777
}
7878

79-
if (MI.getOperand(0).isFI() && MI.getOperand(1).isImm() &&
80-
MI.getOperand(1).getImm() == 0) {
81-
FrameIndex = MI.getOperand(0).getIndex();
82-
return MI.getOperand(2).getReg();
79+
if (MI.getOperand(1).isFI() && MI.getOperand(2).isImm() &&
80+
MI.getOperand(2).getImm() == 0) {
81+
FrameIndex = MI.getOperand(1).getIndex();
82+
return MI.getOperand(0).getReg();
8383
}
8484

8585
return 0;

llvm/test/CodeGen/RISCV/stack-store-check.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ define void @main() local_unnamed_addr nounwind {
9898
; CHECK-NEXT: sw a0, 308(sp)
9999
; CHECK-NEXT: sw a3, 304(sp)
100100
; CHECK-NEXT: sw a2, 300(sp)
101-
; CHECK-NEXT: lw a0, 52(sp)
102101
; CHECK-NEXT: sw a1, 296(sp)
103102
; CHECK-NEXT: sw s11, 324(sp)
104103
; CHECK-NEXT: sw s9, 320(sp)

0 commit comments

Comments
 (0)