1 ; RUN: llc -mtriple arm64-apple-ios -O3 -o - < %s | FileCheck %s
2 ; <rdar://problem/14477220>
4 %class.Complex = type { float, float }
5 %class.Complex_int = type { i32, i32 }
6 %class.Complex_long = type { i64, i64 }
9 ; CHECK: add [[BASE:x[0-9]+]], x0, x1, lsl #3
10 ; CHECK: ldp [[CPLX1_I:s[0-9]+]], [[CPLX1_R:s[0-9]+]], [[[BASE]]]
11 ; CHECK: ldp [[CPLX2_I:s[0-9]+]], [[CPLX2_R:s[0-9]+]], [[[BASE]], #64]
12 ; CHECK: fadd {{s[0-9]+}}, [[CPLX2_I]], [[CPLX1_I]]
13 ; CHECK: fadd {{s[0-9]+}}, [[CPLX2_R]], [[CPLX1_R]]
15 define void @test(ptr nocapture %out, i64 %out_start) {
17 %arrayidx = getelementptr inbounds %class.Complex, ptr %out, i64 %out_start
18 %0 = load i64, ptr %arrayidx, align 4
19 %t0.sroa.0.0.extract.trunc = trunc i64 %0 to i32
20 %1 = bitcast i32 %t0.sroa.0.0.extract.trunc to float
21 %t0.sroa.2.0.extract.shift = lshr i64 %0, 32
22 %t0.sroa.2.0.extract.trunc = trunc i64 %t0.sroa.2.0.extract.shift to i32
23 %2 = bitcast i32 %t0.sroa.2.0.extract.trunc to float
24 %add = add i64 %out_start, 8
25 %arrayidx2 = getelementptr inbounds %class.Complex, ptr %out, i64 %add
26 %3 = load float, ptr %arrayidx2, align 4
27 %add.i = fadd float %3, %1
28 %retval.sroa.0.0.vec.insert.i = insertelement <2 x float> undef, float %add.i, i32 0
29 %r.i = getelementptr inbounds %class.Complex, ptr %arrayidx2, i64 0, i32 1
30 %4 = load float, ptr %r.i, align 4
31 %add5.i = fadd float %4, %2
32 %retval.sroa.0.4.vec.insert.i = insertelement <2 x float> %retval.sroa.0.0.vec.insert.i, float %add5.i, i32 1
33 store <2 x float> %retval.sroa.0.4.vec.insert.i, ptr %arrayidx, align 4
37 ; CHECK-LABEL: @test_int
38 ; CHECK: add [[BASE:x[0-9]+]], x0, x1, lsl #3
39 ; CHECK: ldp [[CPLX1_I:w[0-9]+]], [[CPLX1_R:w[0-9]+]], [[[BASE]]]
40 ; CHECK: ldp [[CPLX2_I:w[0-9]+]], [[CPLX2_R:w[0-9]+]], [[[BASE]], #64]
41 ; CHECK: add {{w[0-9]+}}, [[CPLX2_I]], [[CPLX1_I]]
42 ; CHECK: add {{w[0-9]+}}, [[CPLX2_R]], [[CPLX1_R]]
44 define void @test_int(ptr nocapture %out, i64 %out_start) {
46 %arrayidx = getelementptr inbounds %class.Complex_int, ptr %out, i64 %out_start
47 %0 = load i64, ptr %arrayidx, align 4
48 %t0.sroa.0.0.extract.trunc = trunc i64 %0 to i32
49 %1 = bitcast i32 %t0.sroa.0.0.extract.trunc to i32
50 %t0.sroa.2.0.extract.shift = lshr i64 %0, 32
51 %t0.sroa.2.0.extract.trunc = trunc i64 %t0.sroa.2.0.extract.shift to i32
52 %2 = bitcast i32 %t0.sroa.2.0.extract.trunc to i32
53 %add = add i64 %out_start, 8
54 %arrayidx2 = getelementptr inbounds %class.Complex_int, ptr %out, i64 %add
55 %3 = load i32, ptr %arrayidx2, align 4
56 %add.i = add i32 %3, %1
57 %retval.sroa.0.0.vec.insert.i = insertelement <2 x i32> undef, i32 %add.i, i32 0
58 %r.i = getelementptr inbounds %class.Complex_int, ptr %arrayidx2, i64 0, i32 1
59 %4 = load i32, ptr %r.i, align 4
60 %add5.i = add i32 %4, %2
61 %retval.sroa.0.4.vec.insert.i = insertelement <2 x i32> %retval.sroa.0.0.vec.insert.i, i32 %add5.i, i32 1
62 store <2 x i32> %retval.sroa.0.4.vec.insert.i, ptr %arrayidx, align 4
66 ; CHECK-LABEL: @test_long
67 ; CHECK: add [[BASE:x[0-9]+]], x0, x1, lsl #4
68 ; CHECK: ldp [[CPLX1_I:x[0-9]+]], [[CPLX1_R:x[0-9]+]], [[[BASE]]]
69 ; CHECK: ldp [[CPLX2_I:x[0-9]+]], [[CPLX2_R:x[0-9]+]], [[[BASE]], #128]
70 ; CHECK: add {{x[0-9]+}}, [[CPLX2_I]], [[CPLX1_I]]
71 ; CHECK: add {{x[0-9]+}}, [[CPLX2_R]], [[CPLX1_R]]
73 define void @test_long(ptr nocapture %out, i64 %out_start) {
75 %arrayidx = getelementptr inbounds %class.Complex_long, ptr %out, i64 %out_start
76 %0 = load i128, ptr %arrayidx, align 4
77 %t0.sroa.0.0.extract.trunc = trunc i128 %0 to i64
78 %1 = bitcast i64 %t0.sroa.0.0.extract.trunc to i64
79 %t0.sroa.2.0.extract.shift = lshr i128 %0, 64
80 %t0.sroa.2.0.extract.trunc = trunc i128 %t0.sroa.2.0.extract.shift to i64
81 %2 = bitcast i64 %t0.sroa.2.0.extract.trunc to i64
82 %add = add i64 %out_start, 8
83 %arrayidx2 = getelementptr inbounds %class.Complex_long, ptr %out, i64 %add
84 %3 = load i64, ptr %arrayidx2, align 4
85 %add.i = add i64 %3, %1
86 %retval.sroa.0.0.vec.insert.i = insertelement <2 x i64> undef, i64 %add.i, i32 0
87 %r.i = getelementptr inbounds %class.Complex_long, ptr %arrayidx2, i32 0, i32 1
88 %4 = load i64, ptr %r.i, align 4
89 %add5.i = add i64 %4, %2
90 %retval.sroa.0.4.vec.insert.i = insertelement <2 x i64> %retval.sroa.0.0.vec.insert.i, i64 %add5.i, i32 1
91 store <2 x i64> %retval.sroa.0.4.vec.insert.i, ptr %arrayidx, align 4