1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s
3
4; The complex floating value will be returned by a single register for LP64 ABI.
5; The test case check that the real part returned by __addsf3 will be
6; cleared upper bits by shifts to avoid corrupting the imaginary part.
7
8define i64 @complex_float_add(i64 %a.coerce, i64 %b.coerce) nounwind {
9; CHECK-LABEL: complex_float_add:
10; CHECK:       # %bb.0: # %entry
11; CHECK-NEXT:    addi sp, sp, -32
12; CHECK-NEXT:    sd ra, 24(sp)
13; CHECK-NEXT:    sd s0, 16(sp)
14; CHECK-NEXT:    sd s1, 8(sp)
15; CHECK-NEXT:    sd s2, 0(sp)
16; CHECK-NEXT:    srli s2, a0, 32
17; CHECK-NEXT:    srli s1, a1, 32
18; CHECK-NEXT:    call __addsf3
19; CHECK-NEXT:    mv s0, a0
20; CHECK-NEXT:    mv a0, s2
21; CHECK-NEXT:    mv a1, s1
22; CHECK-NEXT:    call __addsf3
23; CHECK-NEXT:    slli a0, a0, 32
24; CHECK-NEXT:    slli a1, s0, 32
25; CHECK-NEXT:    srli a1, a1, 32
26; CHECK-NEXT:    or a0, a0, a1
27; CHECK-NEXT:    ld s2, 0(sp)
28; CHECK-NEXT:    ld s1, 8(sp)
29; CHECK-NEXT:    ld s0, 16(sp)
30; CHECK-NEXT:    ld ra, 24(sp)
31; CHECK-NEXT:    addi sp, sp, 32
32; CHECK-NEXT:    ret
33entry:
34  %a.sroa.0.0.extract.trunc = trunc i64 %a.coerce to i32
35  %0 = bitcast i32 %a.sroa.0.0.extract.trunc to float
36  %a.sroa.2.0.extract.shift = lshr i64 %a.coerce, 32
37  %a.sroa.2.0.extract.trunc = trunc i64 %a.sroa.2.0.extract.shift to i32
38  %1 = bitcast i32 %a.sroa.2.0.extract.trunc to float
39  %b.sroa.0.0.extract.trunc = trunc i64 %b.coerce to i32
40  %2 = bitcast i32 %b.sroa.0.0.extract.trunc to float
41  %b.sroa.2.0.extract.shift = lshr i64 %b.coerce, 32
42  %b.sroa.2.0.extract.trunc = trunc i64 %b.sroa.2.0.extract.shift to i32
43  %3 = bitcast i32 %b.sroa.2.0.extract.trunc to float
44  %add.r = fadd float %0, %2
45  %add.i = fadd float %1, %3
46  %4 = bitcast float %add.r to i32
47  %5 = bitcast float %add.i to i32
48  %retval.sroa.2.0.insert.ext = zext i32 %5 to i64
49  %retval.sroa.2.0.insert.shift = shl nuw i64 %retval.sroa.2.0.insert.ext, 32
50  %retval.sroa.0.0.insert.ext = zext i32 %4 to i64
51  %retval.sroa.0.0.insert.insert = or i64 %retval.sroa.2.0.insert.shift, %retval.sroa.0.0.insert.ext
52  ret i64 %retval.sroa.0.0.insert.insert
53}
54