Skip to content

Commit ea4bf34

Browse files
authored
[RISCV] Add Zilsd to RISCVMergeBaseOffset. (#140157)
I only tested a simple case for folding the addi from medany codemodel. I assume everything else should just work.
1 parent dcd62f3 commit ea4bf34

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ bool RISCVMergeBaseOffsetOpt::foldIntoMemoryOps(MachineInstr &Hi,
409409
case RISCV::LHU:
410410
case RISCV::LWU:
411411
case RISCV::LD:
412+
case RISCV::LD_RV32:
412413
case RISCV::FLH:
413414
case RISCV::FLW:
414415
case RISCV::FLD:
@@ -418,6 +419,7 @@ bool RISCVMergeBaseOffsetOpt::foldIntoMemoryOps(MachineInstr &Hi,
418419
case RISCV::SW:
419420
case RISCV::SW_INX:
420421
case RISCV::SD:
422+
case RISCV::SD_RV32:
421423
case RISCV::FSH:
422424
case RISCV::FSW:
423425
case RISCV::FSD: {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=riscv32 -mattr=+zdinx,+zilsd -verify-machineinstrs \
3+
; RUN: -code-model=medium < %s | FileCheck %s
4+
5+
@g_0 = global double 0.0
6+
7+
define double @load_g_0() nounwind {
8+
; CHECK-LABEL: load_g_0:
9+
; CHECK: # %bb.0: # %entry
10+
; CHECK-NEXT: .Lpcrel_hi0:
11+
; CHECK-NEXT: auipc a0, %pcrel_hi(g_0)
12+
; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0)
13+
; CHECK-NEXT: ret
14+
entry:
15+
%0 = load double, ptr @g_0
16+
ret double %0
17+
}
18+
19+
define void @store_g_0() nounwind {
20+
; CHECK-LABEL: store_g_0:
21+
; CHECK: # %bb.0: # %entry
22+
; CHECK-NEXT: .Lpcrel_hi1:
23+
; CHECK-NEXT: auipc a0, %pcrel_hi(g_0)
24+
; CHECK-NEXT: fcvt.d.w a2, zero
25+
; CHECK-NEXT: sd a2, %pcrel_lo(.Lpcrel_hi1)(a0)
26+
; CHECK-NEXT: ret
27+
entry:
28+
store double 0.0, ptr @g_0
29+
ret void
30+
}

0 commit comments

Comments
 (0)