File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -767,8 +767,15 @@ void RISCVInstrInfo::movImm(MachineBasicBlock &MBB,
767
767
bool DstIsDead) const {
768
768
Register SrcReg = RISCV::X0;
769
769
770
- if (!STI.is64Bit () && !isInt<32 >(Val))
771
- report_fatal_error (" Should only materialize 32-bit constants for RV32" );
770
+ // For RV32, allow a sign or unsigned 32 bit value.
771
+ if (!STI.is64Bit () && !isInt<32 >(Val)) {
772
+ // If have a uimm32 it will still fit in a register so we can allow it.
773
+ if (!isUInt<32 >(Val))
774
+ report_fatal_error (" Should only materialize 32-bit constants for RV32" );
775
+
776
+ // Sign extend for generateInstSeq.
777
+ Val = SignExtend64<32 >(Val);
778
+ }
772
779
773
780
RISCVMatInt::InstSeq Seq = RISCVMatInt::generateInstSeq (Val, STI);
774
781
assert (!Seq.empty ());
Original file line number Diff line number Diff line change
1
+ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2
+ ; RUN: llc < %s -mtriple=riscv32 | FileCheck %s
3
+
4
+ define void @foo () {
5
+ ; CHECK-LABEL: foo:
6
+ ; CHECK: # %bb.0:
7
+ ; CHECK-NEXT: addi sp, sp, -2032
8
+ ; CHECK-NEXT: .cfi_def_cfa_offset 2032
9
+ ; CHECK-NEXT: sw ra, 2028(sp) # 4-byte Folded Spill
10
+ ; CHECK-NEXT: .cfi_offset ra, -4
11
+ ; CHECK-NEXT: li a0, -2048
12
+ ; CHECK-NEXT: sub sp, sp, a0
13
+ ; CHECK-NEXT: .cfi_def_cfa_offset -16
14
+ ; CHECK-NEXT: addi a0, sp, 4
15
+ ; CHECK-NEXT: call use
16
+ ; CHECK-NEXT: li a0, -2048
17
+ ; CHECK-NEXT: add sp, sp, a0
18
+ ; CHECK-NEXT: lw ra, 2028(sp) # 4-byte Folded Reload
19
+ ; CHECK-NEXT: addi sp, sp, 2032
20
+ ; CHECK-NEXT: ret
21
+ %1 = alloca [1073741818 x i32 ], align 4
22
+ call void @use (ptr %1 )
23
+ ret void
24
+ }
25
+
26
+ declare void @use (ptr )
You can’t perform that action at this time.
0 commit comments