1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d -verify-machineinstrs < %s \
3 ; RUN: | FileCheck -check-prefix=RV32IFD %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+d -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefix=RV64IFD %s
7 define double @double_imm() nounwind {
8 ; TODO: Should probably prefer fld or ld on RV64 rather than materialising an
11 ; RV32IFD-LABEL: double_imm:
13 ; RV32IFD-NEXT: addi sp, sp, -16
14 ; RV32IFD-NEXT: lui a0, %hi(.LCPI0_0)
15 ; RV32IFD-NEXT: addi a0, a0, %lo(.LCPI0_0)
16 ; RV32IFD-NEXT: fld ft0, 0(a0)
17 ; RV32IFD-NEXT: fsd ft0, 8(sp)
18 ; RV32IFD-NEXT: lw a0, 8(sp)
19 ; RV32IFD-NEXT: lw a1, 12(sp)
20 ; RV32IFD-NEXT: addi sp, sp, 16
23 ; RV64IFD-LABEL: double_imm:
25 ; RV64IFD-NEXT: lui a0, 512
26 ; RV64IFD-NEXT: addiw a0, a0, 1169
27 ; RV64IFD-NEXT: slli a0, a0, 15
28 ; RV64IFD-NEXT: addi a0, a0, -299
29 ; RV64IFD-NEXT: slli a0, a0, 14
30 ; RV64IFD-NEXT: addi a0, a0, 1091
31 ; RV64IFD-NEXT: slli a0, a0, 12
32 ; RV64IFD-NEXT: addi a0, a0, -744
34 ret double 3.1415926535897931159979634685441851615905761718750
37 define double @double_imm_op(double %a) nounwind {
38 ; RV32IFD-LABEL: double_imm_op:
40 ; RV32IFD-NEXT: addi sp, sp, -16
41 ; RV32IFD-NEXT: sw a0, 8(sp)
42 ; RV32IFD-NEXT: sw a1, 12(sp)
43 ; RV32IFD-NEXT: fld ft0, 8(sp)
44 ; RV32IFD-NEXT: lui a0, %hi(.LCPI1_0)
45 ; RV32IFD-NEXT: addi a0, a0, %lo(.LCPI1_0)
46 ; RV32IFD-NEXT: fld ft1, 0(a0)
47 ; RV32IFD-NEXT: fadd.d ft0, ft0, ft1
48 ; RV32IFD-NEXT: fsd ft0, 8(sp)
49 ; RV32IFD-NEXT: lw a0, 8(sp)
50 ; RV32IFD-NEXT: lw a1, 12(sp)
51 ; RV32IFD-NEXT: addi sp, sp, 16
54 ; RV64IFD-LABEL: double_imm_op:
56 ; RV64IFD-NEXT: fmv.d.x ft0, a0
57 ; RV64IFD-NEXT: lui a0, %hi(.LCPI1_0)
58 ; RV64IFD-NEXT: addi a0, a0, %lo(.LCPI1_0)
59 ; RV64IFD-NEXT: fld ft1, 0(a0)
60 ; RV64IFD-NEXT: fadd.d ft0, ft0, ft1
61 ; RV64IFD-NEXT: fmv.x.d a0, ft0
63 %1 = fadd double %a, 1.0