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 6 7define double @double_imm() nounwind { 8; TODO: Should probably prefer fld or ld on RV64 rather than materialising an 9; expensive constant. 10; 11; RV32IFD-LABEL: double_imm: 12; RV32IFD: # %bb.0: 13; RV32IFD-NEXT: lui a0, 345155 14; RV32IFD-NEXT: addi a0, a0, -744 15; RV32IFD-NEXT: lui a1, 262290 16; RV32IFD-NEXT: addi a1, a1, 507 17; RV32IFD-NEXT: ret 18; 19; RV64IFD-LABEL: double_imm: 20; RV64IFD: # %bb.0: 21; RV64IFD-NEXT: lui a0, 512 22; RV64IFD-NEXT: addiw a0, a0, 1169 23; RV64IFD-NEXT: slli a0, a0, 15 24; RV64IFD-NEXT: addi a0, a0, -299 25; RV64IFD-NEXT: slli a0, a0, 14 26; RV64IFD-NEXT: addi a0, a0, 1091 27; RV64IFD-NEXT: slli a0, a0, 12 28; RV64IFD-NEXT: addi a0, a0, -744 29; RV64IFD-NEXT: ret 30 ret double 3.1415926535897931159979634685441851615905761718750 31} 32 33define double @double_imm_op(double %a) nounwind { 34; RV32IFD-LABEL: double_imm_op: 35; RV32IFD: # %bb.0: 36; RV32IFD-NEXT: addi sp, sp, -16 37; RV32IFD-NEXT: sw a0, 8(sp) 38; RV32IFD-NEXT: sw a1, 12(sp) 39; RV32IFD-NEXT: fld ft0, 8(sp) 40; RV32IFD-NEXT: lui a0, %hi(.LCPI1_0) 41; RV32IFD-NEXT: fld ft1, %lo(.LCPI1_0)(a0) 42; RV32IFD-NEXT: fadd.d ft0, ft0, ft1 43; RV32IFD-NEXT: fsd ft0, 8(sp) 44; RV32IFD-NEXT: lw a0, 8(sp) 45; RV32IFD-NEXT: lw a1, 12(sp) 46; RV32IFD-NEXT: addi sp, sp, 16 47; RV32IFD-NEXT: ret 48; 49; RV64IFD-LABEL: double_imm_op: 50; RV64IFD: # %bb.0: 51; RV64IFD-NEXT: lui a1, %hi(.LCPI1_0) 52; RV64IFD-NEXT: fld ft0, %lo(.LCPI1_0)(a1) 53; RV64IFD-NEXT: fmv.d.x ft1, a0 54; RV64IFD-NEXT: fadd.d ft0, ft1, ft0 55; RV64IFD-NEXT: fmv.x.d a0, ft0 56; RV64IFD-NEXT: ret 57 %1 = fadd double %a, 1.0 58 ret double %1 59} 60