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 @func(double %d, i32 %n) nounwind {
9 ; RV32IFD: # %bb.0: # %entry
10 ; RV32IFD-NEXT: addi sp, sp, -32
11 ; RV32IFD-NEXT: sw ra, 28(sp)
12 ; RV32IFD-NEXT: sw a0, 16(sp)
13 ; RV32IFD-NEXT: sw a1, 20(sp)
14 ; RV32IFD-NEXT: fld ft0, 16(sp)
15 ; RV32IFD-NEXT: beqz a2, .LBB0_2
16 ; RV32IFD-NEXT: # %bb.1: # %if.else
17 ; RV32IFD-NEXT: addi a2, a2, -1
18 ; RV32IFD-NEXT: fsd ft0, 16(sp)
19 ; RV32IFD-NEXT: lw a0, 16(sp)
20 ; RV32IFD-NEXT: lw a1, 20(sp)
21 ; RV32IFD-NEXT: fsd ft0, 8(sp)
22 ; RV32IFD-NEXT: call func
23 ; RV32IFD-NEXT: sw a0, 16(sp)
24 ; RV32IFD-NEXT: sw a1, 20(sp)
25 ; RV32IFD-NEXT: fld ft0, 16(sp)
26 ; RV32IFD-NEXT: fld ft1, 8(sp)
27 ; RV32IFD-NEXT: fadd.d ft0, ft0, ft1
28 ; RV32IFD-NEXT: .LBB0_2: # %return
29 ; RV32IFD-NEXT: fsd ft0, 16(sp)
30 ; RV32IFD-NEXT: lw a0, 16(sp)
31 ; RV32IFD-NEXT: lw a1, 20(sp)
32 ; RV32IFD-NEXT: lw ra, 28(sp)
33 ; RV32IFD-NEXT: addi sp, sp, 32
36 ; RV64IFD-LABEL: func:
37 ; RV64IFD: # %bb.0: # %entry
38 ; RV64IFD-NEXT: addi sp, sp, -16
39 ; RV64IFD-NEXT: sd ra, 8(sp)
40 ; RV64IFD-NEXT: slli a2, a1, 32
41 ; RV64IFD-NEXT: srli a2, a2, 32
42 ; RV64IFD-NEXT: fmv.d.x ft0, a0
43 ; RV64IFD-NEXT: beqz a2, .LBB0_2
44 ; RV64IFD-NEXT: # %bb.1: # %if.else
45 ; RV64IFD-NEXT: addi a1, a1, -1
46 ; RV64IFD-NEXT: fmv.x.d a0, ft0
47 ; RV64IFD-NEXT: fsd ft0, 0(sp)
48 ; RV64IFD-NEXT: call func
49 ; RV64IFD-NEXT: fmv.d.x ft0, a0
50 ; RV64IFD-NEXT: fld ft1, 0(sp)
51 ; RV64IFD-NEXT: fadd.d ft0, ft0, ft1
52 ; RV64IFD-NEXT: .LBB0_2: # %return
53 ; RV64IFD-NEXT: fmv.x.d a0, ft0
54 ; RV64IFD-NEXT: ld ra, 8(sp)
55 ; RV64IFD-NEXT: addi sp, sp, 16
58 %cmp = icmp eq i32 %n, 0
59 br i1 %cmp, label %return, label %if.else
63 %call = tail call double @func(double %d, i32 %sub)
64 %add = fadd double %call, %d