1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown -ppc-vsr-nums-as-vr \
3; RUN:   -verify-machineinstrs -ppc-asm-full-reg-names < %s | FileCheck %s
4; RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-unknown -ppc-vsr-nums-as-vr \
5; RUN:   -verify-machineinstrs -ppc-asm-full-reg-names < %s | FileCheck %s \
6; RUN:   -check-prefix=CHECK-P8
7
8; Function Attrs: norecurse nounwind readnone
9define fp128 @loadConstant() {
10; CHECK-LABEL: loadConstant:
11; CHECK:       # %bb.0: # %entry
12; CHECK-NEXT:    addis r3, r2, .LCPI0_0@toc@ha
13; CHECK-NEXT:    addi r3, r3, .LCPI0_0@toc@l
14; CHECK-NEXT:    lxvx v2, 0, r3
15; CHECK-NEXT:    blr
16;
17; CHECK-P8-LABEL: loadConstant:
18; CHECK-P8:       # %bb.0: # %entry
19; CHECK-P8-NEXT:    lis r3, 1
20; CHECK-P8-NEXT:    ori r3, r3, 5
21; CHECK-P8-NEXT:    rldic r4, r3, 46, 1
22; CHECK-P8-NEXT:    li r3, 0
23; CHECK-P8-NEXT:    blr
24  entry:
25    ret fp128 0xL00000000000000004001400000000000
26}
27
28; Function Attrs: norecurse nounwind readnone
29define fp128 @loadConstant2(fp128 %a, fp128 %b) {
30; CHECK-LABEL: loadConstant2:
31; CHECK:       # %bb.0: # %entry
32; CHECK-NEXT:    xsaddqp v2, v2, v3
33; CHECK-NEXT:    addis r3, r2, .LCPI1_0@toc@ha
34; CHECK-NEXT:    addi r3, r3, .LCPI1_0@toc@l
35; CHECK-NEXT:    lxvx v3, 0, r3
36; CHECK-NEXT:    xsaddqp v2, v2, v3
37; CHECK-NEXT:    blr
38;
39; CHECK-P8-LABEL: loadConstant2:
40; CHECK-P8:       # %bb.0: # %entry
41; CHECK-P8-NEXT:    mflr r0
42; CHECK-P8-NEXT:    std r0, 16(r1)
43; CHECK-P8-NEXT:    stdu r1, -32(r1)
44; CHECK-P8-NEXT:    .cfi_def_cfa_offset 32
45; CHECK-P8-NEXT:    .cfi_offset lr, 16
46; CHECK-P8-NEXT:    bl __addkf3
47; CHECK-P8-NEXT:    nop
48; CHECK-P8-NEXT:    lis r5, 1
49; CHECK-P8-NEXT:    ori r5, r5, 5
50; CHECK-P8-NEXT:    rldic r6, r5, 46, 1
51; CHECK-P8-NEXT:    li r5, 0
52; CHECK-P8-NEXT:    bl __addkf3
53; CHECK-P8-NEXT:    nop
54; CHECK-P8-NEXT:    addi r1, r1, 32
55; CHECK-P8-NEXT:    ld r0, 16(r1)
56; CHECK-P8-NEXT:    mtlr r0
57; CHECK-P8-NEXT:    blr
58  entry:
59    %add = fadd fp128 %a, %b
60      %add1 = fadd fp128 %add, 0xL00000000000000004001400000000000
61        ret fp128 %add1
62}
63
64; Test passing float128 by value.
65; Function Attrs: norecurse nounwind readnone
66define signext i32 @fp128Param(fp128 %a) {
67; CHECK-LABEL: fp128Param:
68; CHECK:       # %bb.0: # %entry
69; CHECK-NEXT:    xscvqpswz v2, v2
70; CHECK-NEXT:    mfvsrwz r3, v2
71; CHECK-NEXT:    extsw r3, r3
72; CHECK-NEXT:    blr
73;
74; CHECK-P8-LABEL: fp128Param:
75; CHECK-P8:       # %bb.0: # %entry
76; CHECK-P8-NEXT:    mflr r0
77; CHECK-P8-NEXT:    std r0, 16(r1)
78; CHECK-P8-NEXT:    stdu r1, -32(r1)
79; CHECK-P8-NEXT:    .cfi_def_cfa_offset 32
80; CHECK-P8-NEXT:    .cfi_offset lr, 16
81; CHECK-P8-NEXT:    bl __fixkfsi
82; CHECK-P8-NEXT:    nop
83; CHECK-P8-NEXT:    extsw r3, r3
84; CHECK-P8-NEXT:    addi r1, r1, 32
85; CHECK-P8-NEXT:    ld r0, 16(r1)
86; CHECK-P8-NEXT:    mtlr r0
87; CHECK-P8-NEXT:    blr
88entry:
89  %conv = fptosi fp128 %a to i32
90  ret i32 %conv
91}
92
93; Test float128 as return value.
94; Function Attrs: norecurse nounwind readnone
95define fp128 @fp128Return(fp128 %a, fp128 %b) {
96; CHECK-LABEL: fp128Return:
97; CHECK:       # %bb.0: # %entry
98; CHECK-NEXT:    xsaddqp v2, v2, v3
99; CHECK-NEXT:    blr
100;
101; CHECK-P8-LABEL: fp128Return:
102; CHECK-P8:       # %bb.0: # %entry
103; CHECK-P8-NEXT:    mflr r0
104; CHECK-P8-NEXT:    std r0, 16(r1)
105; CHECK-P8-NEXT:    stdu r1, -32(r1)
106; CHECK-P8-NEXT:    .cfi_def_cfa_offset 32
107; CHECK-P8-NEXT:    .cfi_offset lr, 16
108; CHECK-P8-NEXT:    bl __addkf3
109; CHECK-P8-NEXT:    nop
110; CHECK-P8-NEXT:    addi r1, r1, 32
111; CHECK-P8-NEXT:    ld r0, 16(r1)
112; CHECK-P8-NEXT:    mtlr r0
113; CHECK-P8-NEXT:    blr
114entry:
115  %add = fadd fp128 %a, %b
116  ret fp128 %add
117}
118
119; array of float128 types
120; Function Attrs: norecurse nounwind readonly
121define fp128 @fp128Array(fp128* nocapture readonly %farray,
122; CHECK-LABEL: fp128Array:
123; CHECK:       # %bb.0: # %entry
124; CHECK-NEXT:    sldi r4, r4, 4
125; CHECK-NEXT:    lxv v2, 0(r3)
126; CHECK-NEXT:    add r3, r3, r4
127; CHECK-NEXT:    lxv v3, -16(r3)
128; CHECK-NEXT:    xsaddqp v2, v2, v3
129; CHECK-NEXT:    blr
130;
131; CHECK-P8-LABEL: fp128Array:
132; CHECK-P8:       # %bb.0: # %entry
133; CHECK-P8-NEXT:    mflr r0
134; CHECK-P8-NEXT:    std r0, 16(r1)
135; CHECK-P8-NEXT:    stdu r1, -32(r1)
136; CHECK-P8-NEXT:    .cfi_def_cfa_offset 32
137; CHECK-P8-NEXT:    .cfi_offset lr, 16
138; CHECK-P8-NEXT:    sldi r4, r4, 4
139; CHECK-P8-NEXT:    ld r7, 0(r3)
140; CHECK-P8-NEXT:    add r6, r3, r4
141; CHECK-P8-NEXT:    ld r4, 8(r3)
142; CHECK-P8-NEXT:    ld r5, -16(r6)
143; CHECK-P8-NEXT:    ld r6, -8(r6)
144; CHECK-P8-NEXT:    mr r3, r7
145; CHECK-P8-NEXT:    bl __addkf3
146; CHECK-P8-NEXT:    nop
147; CHECK-P8-NEXT:    addi r1, r1, 32
148; CHECK-P8-NEXT:    ld r0, 16(r1)
149; CHECK-P8-NEXT:    mtlr r0
150; CHECK-P8-NEXT:    blr
151                         i32 signext %loopcnt, fp128* nocapture readnone %sum) {
152entry:
153  %0 = load fp128, fp128* %farray, align 16
154  %sub = add nsw i32 %loopcnt, -1
155  %idxprom = sext i32 %sub to i64
156  %arrayidx1 = getelementptr inbounds fp128, fp128* %farray, i64 %idxprom
157  %1 = load fp128, fp128* %arrayidx1, align 16
158  %add = fadd fp128 %0, %1
159  ret fp128 %add
160}
161
162; Up to 12 qualified floating-point arguments can be passed in v2-v13.
163; Function to test passing 13 float128 parameters.
164; Function Attrs: norecurse nounwind readnone
165define fp128 @maxVecParam(fp128 %p1, fp128 %p2, fp128 %p3, fp128 %p4, fp128 %p5,
166; CHECK-LABEL: maxVecParam:
167; CHECK:       # %bb.0: # %entry
168; CHECK-NEXT:    xsaddqp v2, v2, v3
169; CHECK-NEXT:    lxv v0, 224(r1)
170; CHECK-NEXT:    xsaddqp v2, v2, v4
171; CHECK-NEXT:    xsaddqp v2, v2, v5
172; CHECK-NEXT:    xsaddqp v2, v2, v6
173; CHECK-NEXT:    xsaddqp v2, v2, v7
174; CHECK-NEXT:    xsaddqp v2, v2, v8
175; CHECK-NEXT:    xsaddqp v2, v2, v9
176; CHECK-NEXT:    xsaddqp v2, v2, v10
177; CHECK-NEXT:    xsaddqp v2, v2, v11
178; CHECK-NEXT:    xsaddqp v2, v2, v12
179; CHECK-NEXT:    xsaddqp v2, v2, v13
180; CHECK-NEXT:    xssubqp v2, v2, v0
181; CHECK-NEXT:    blr
182;
183; CHECK-P8-LABEL: maxVecParam:
184; CHECK-P8:       # %bb.0: # %entry
185; CHECK-P8-NEXT:    mflr r0
186; CHECK-P8-NEXT:    .cfi_def_cfa_offset 208
187; CHECK-P8-NEXT:    .cfi_offset lr, 16
188; CHECK-P8-NEXT:    .cfi_offset r14, -144
189; CHECK-P8-NEXT:    .cfi_offset r15, -136
190; CHECK-P8-NEXT:    .cfi_offset r16, -128
191; CHECK-P8-NEXT:    .cfi_offset r17, -120
192; CHECK-P8-NEXT:    .cfi_offset r18, -112
193; CHECK-P8-NEXT:    .cfi_offset r19, -104
194; CHECK-P8-NEXT:    .cfi_offset r20, -96
195; CHECK-P8-NEXT:    .cfi_offset r21, -88
196; CHECK-P8-NEXT:    .cfi_offset r22, -80
197; CHECK-P8-NEXT:    .cfi_offset r23, -72
198; CHECK-P8-NEXT:    .cfi_offset r24, -64
199; CHECK-P8-NEXT:    .cfi_offset r25, -56
200; CHECK-P8-NEXT:    .cfi_offset r26, -48
201; CHECK-P8-NEXT:    .cfi_offset r27, -40
202; CHECK-P8-NEXT:    .cfi_offset r28, -32
203; CHECK-P8-NEXT:    .cfi_offset r29, -24
204; CHECK-P8-NEXT:    .cfi_offset r30, -16
205; CHECK-P8-NEXT:    .cfi_offset r31, -8
206; CHECK-P8-NEXT:    std r14, -144(r1) # 8-byte Folded Spill
207; CHECK-P8-NEXT:    std r15, -136(r1) # 8-byte Folded Spill
208; CHECK-P8-NEXT:    std r16, -128(r1) # 8-byte Folded Spill
209; CHECK-P8-NEXT:    std r17, -120(r1) # 8-byte Folded Spill
210; CHECK-P8-NEXT:    std r18, -112(r1) # 8-byte Folded Spill
211; CHECK-P8-NEXT:    std r19, -104(r1) # 8-byte Folded Spill
212; CHECK-P8-NEXT:    std r20, -96(r1) # 8-byte Folded Spill
213; CHECK-P8-NEXT:    std r21, -88(r1) # 8-byte Folded Spill
214; CHECK-P8-NEXT:    std r22, -80(r1) # 8-byte Folded Spill
215; CHECK-P8-NEXT:    std r23, -72(r1) # 8-byte Folded Spill
216; CHECK-P8-NEXT:    std r24, -64(r1) # 8-byte Folded Spill
217; CHECK-P8-NEXT:    std r25, -56(r1) # 8-byte Folded Spill
218; CHECK-P8-NEXT:    std r26, -48(r1) # 8-byte Folded Spill
219; CHECK-P8-NEXT:    std r27, -40(r1) # 8-byte Folded Spill
220; CHECK-P8-NEXT:    std r28, -32(r1) # 8-byte Folded Spill
221; CHECK-P8-NEXT:    std r29, -24(r1) # 8-byte Folded Spill
222; CHECK-P8-NEXT:    std r30, -16(r1) # 8-byte Folded Spill
223; CHECK-P8-NEXT:    std r31, -8(r1) # 8-byte Folded Spill
224; CHECK-P8-NEXT:    std r0, 16(r1)
225; CHECK-P8-NEXT:    stdu r1, -208(r1)
226; CHECK-P8-NEXT:    mr r17, r7
227; CHECK-P8-NEXT:    ld r7, 432(r1)
228; CHECK-P8-NEXT:    ld r26, 400(r1)
229; CHECK-P8-NEXT:    ld r25, 408(r1)
230; CHECK-P8-NEXT:    ld r24, 384(r1)
231; CHECK-P8-NEXT:    mr r20, r10
232; CHECK-P8-NEXT:    ld r23, 392(r1)
233; CHECK-P8-NEXT:    ld r22, 368(r1)
234; CHECK-P8-NEXT:    ld r21, 376(r1)
235; CHECK-P8-NEXT:    ld r16, 352(r1)
236; CHECK-P8-NEXT:    mr r19, r9
237; CHECK-P8-NEXT:    mr r18, r8
238; CHECK-P8-NEXT:    ld r15, 360(r1)
239; CHECK-P8-NEXT:    ld r14, 336(r1)
240; CHECK-P8-NEXT:    ld r31, 344(r1)
241; CHECK-P8-NEXT:    ld r30, 320(r1)
242; CHECK-P8-NEXT:    std r7, 56(r1) # 8-byte Folded Spill
243; CHECK-P8-NEXT:    ld r7, 440(r1)
244; CHECK-P8-NEXT:    ld r29, 328(r1)
245; CHECK-P8-NEXT:    ld r28, 304(r1)
246; CHECK-P8-NEXT:    ld r27, 312(r1)
247; CHECK-P8-NEXT:    std r7, 48(r1) # 8-byte Folded Spill
248; CHECK-P8-NEXT:    ld r7, 416(r1)
249; CHECK-P8-NEXT:    std r7, 40(r1) # 8-byte Folded Spill
250; CHECK-P8-NEXT:    ld r7, 424(r1)
251; CHECK-P8-NEXT:    std r7, 32(r1) # 8-byte Folded Spill
252; CHECK-P8-NEXT:    bl __addkf3
253; CHECK-P8-NEXT:    nop
254; CHECK-P8-NEXT:    mr r5, r17
255; CHECK-P8-NEXT:    mr r6, r18
256; CHECK-P8-NEXT:    bl __addkf3
257; CHECK-P8-NEXT:    nop
258; CHECK-P8-NEXT:    mr r5, r19
259; CHECK-P8-NEXT:    mr r6, r20
260; CHECK-P8-NEXT:    bl __addkf3
261; CHECK-P8-NEXT:    nop
262; CHECK-P8-NEXT:    mr r5, r28
263; CHECK-P8-NEXT:    mr r6, r27
264; CHECK-P8-NEXT:    bl __addkf3
265; CHECK-P8-NEXT:    nop
266; CHECK-P8-NEXT:    mr r5, r30
267; CHECK-P8-NEXT:    mr r6, r29
268; CHECK-P8-NEXT:    bl __addkf3
269; CHECK-P8-NEXT:    nop
270; CHECK-P8-NEXT:    mr r5, r14
271; CHECK-P8-NEXT:    mr r6, r31
272; CHECK-P8-NEXT:    bl __addkf3
273; CHECK-P8-NEXT:    nop
274; CHECK-P8-NEXT:    mr r5, r16
275; CHECK-P8-NEXT:    mr r6, r15
276; CHECK-P8-NEXT:    bl __addkf3
277; CHECK-P8-NEXT:    nop
278; CHECK-P8-NEXT:    mr r5, r22
279; CHECK-P8-NEXT:    mr r6, r21
280; CHECK-P8-NEXT:    bl __addkf3
281; CHECK-P8-NEXT:    nop
282; CHECK-P8-NEXT:    mr r5, r24
283; CHECK-P8-NEXT:    mr r6, r23
284; CHECK-P8-NEXT:    bl __addkf3
285; CHECK-P8-NEXT:    nop
286; CHECK-P8-NEXT:    mr r5, r26
287; CHECK-P8-NEXT:    mr r6, r25
288; CHECK-P8-NEXT:    bl __addkf3
289; CHECK-P8-NEXT:    nop
290; CHECK-P8-NEXT:    ld r5, 40(r1) # 8-byte Folded Reload
291; CHECK-P8-NEXT:    ld r6, 32(r1) # 8-byte Folded Reload
292; CHECK-P8-NEXT:    bl __addkf3
293; CHECK-P8-NEXT:    nop
294; CHECK-P8-NEXT:    ld r5, 56(r1) # 8-byte Folded Reload
295; CHECK-P8-NEXT:    ld r6, 48(r1) # 8-byte Folded Reload
296; CHECK-P8-NEXT:    bl __subkf3
297; CHECK-P8-NEXT:    nop
298; CHECK-P8-NEXT:    addi r1, r1, 208
299; CHECK-P8-NEXT:    ld r0, 16(r1)
300; CHECK-P8-NEXT:    ld r31, -8(r1) # 8-byte Folded Reload
301; CHECK-P8-NEXT:    ld r30, -16(r1) # 8-byte Folded Reload
302; CHECK-P8-NEXT:    ld r29, -24(r1) # 8-byte Folded Reload
303; CHECK-P8-NEXT:    ld r28, -32(r1) # 8-byte Folded Reload
304; CHECK-P8-NEXT:    ld r27, -40(r1) # 8-byte Folded Reload
305; CHECK-P8-NEXT:    ld r26, -48(r1) # 8-byte Folded Reload
306; CHECK-P8-NEXT:    ld r25, -56(r1) # 8-byte Folded Reload
307; CHECK-P8-NEXT:    ld r24, -64(r1) # 8-byte Folded Reload
308; CHECK-P8-NEXT:    ld r23, -72(r1) # 8-byte Folded Reload
309; CHECK-P8-NEXT:    ld r22, -80(r1) # 8-byte Folded Reload
310; CHECK-P8-NEXT:    ld r21, -88(r1) # 8-byte Folded Reload
311; CHECK-P8-NEXT:    mtlr r0
312; CHECK-P8-NEXT:    ld r20, -96(r1) # 8-byte Folded Reload
313; CHECK-P8-NEXT:    ld r19, -104(r1) # 8-byte Folded Reload
314; CHECK-P8-NEXT:    ld r18, -112(r1) # 8-byte Folded Reload
315; CHECK-P8-NEXT:    ld r17, -120(r1) # 8-byte Folded Reload
316; CHECK-P8-NEXT:    ld r16, -128(r1) # 8-byte Folded Reload
317; CHECK-P8-NEXT:    ld r15, -136(r1) # 8-byte Folded Reload
318; CHECK-P8-NEXT:    ld r14, -144(r1) # 8-byte Folded Reload
319; CHECK-P8-NEXT:    blr
320                          fp128 %p6, fp128 %p7, fp128 %p8, fp128 %p9, fp128 %p10,
321                          fp128 %p11, fp128 %p12, fp128 %p13) {
322entry:
323  %add = fadd fp128 %p1, %p2
324  %add1 = fadd fp128 %add, %p3
325  %add2 = fadd fp128 %add1, %p4
326  %add3 = fadd fp128 %add2, %p5
327  %add4 = fadd fp128 %add3, %p6
328  %add5 = fadd fp128 %add4, %p7
329  %add6 = fadd fp128 %add5, %p8
330  %add7 = fadd fp128 %add6, %p9
331  %add8 = fadd fp128 %add7, %p10
332  %add9 = fadd fp128 %add8, %p11
333  %add10 = fadd fp128 %add9, %p12
334  %sub = fsub fp128 %add10, %p13
335  ret fp128 %sub
336}
337
338; Passing a mix of float128 and other type parameters.
339; Function Attrs: norecurse nounwind readnone
340define fp128 @mixParam_01(fp128 %a, i32 signext %i, fp128 %b) {
341; CHECK-LABEL: mixParam_01:
342; CHECK:       # %bb.0: # %entry
343; CHECK-NEXT:    xsaddqp v2, v2, v3
344; CHECK-NEXT:    mtvsrwa v3, r5
345; CHECK-NEXT:    xscvsdqp v3, v3
346; CHECK-NEXT:    xsaddqp v2, v2, v3
347; CHECK-NEXT:    blr
348;
349; CHECK-P8-LABEL: mixParam_01:
350; CHECK-P8:       # %bb.0: # %entry
351; CHECK-P8-NEXT:    mflr r0
352; CHECK-P8-NEXT:    .cfi_def_cfa_offset 64
353; CHECK-P8-NEXT:    .cfi_offset lr, 16
354; CHECK-P8-NEXT:    .cfi_offset r28, -32
355; CHECK-P8-NEXT:    .cfi_offset r29, -24
356; CHECK-P8-NEXT:    .cfi_offset r30, -16
357; CHECK-P8-NEXT:    std r28, -32(r1) # 8-byte Folded Spill
358; CHECK-P8-NEXT:    std r29, -24(r1) # 8-byte Folded Spill
359; CHECK-P8-NEXT:    std r30, -16(r1) # 8-byte Folded Spill
360; CHECK-P8-NEXT:    std r0, 16(r1)
361; CHECK-P8-NEXT:    stdu r1, -64(r1)
362; CHECK-P8-NEXT:    mr r30, r5
363; CHECK-P8-NEXT:    mr r5, r6
364; CHECK-P8-NEXT:    mr r6, r7
365; CHECK-P8-NEXT:    bl __addkf3
366; CHECK-P8-NEXT:    nop
367; CHECK-P8-NEXT:    mr r29, r3
368; CHECK-P8-NEXT:    mr r3, r30
369; CHECK-P8-NEXT:    mr r28, r4
370; CHECK-P8-NEXT:    bl __floatsikf
371; CHECK-P8-NEXT:    nop
372; CHECK-P8-NEXT:    mr r5, r3
373; CHECK-P8-NEXT:    mr r6, r4
374; CHECK-P8-NEXT:    mr r3, r29
375; CHECK-P8-NEXT:    mr r4, r28
376; CHECK-P8-NEXT:    bl __addkf3
377; CHECK-P8-NEXT:    nop
378; CHECK-P8-NEXT:    addi r1, r1, 64
379; CHECK-P8-NEXT:    ld r0, 16(r1)
380; CHECK-P8-NEXT:    ld r30, -16(r1) # 8-byte Folded Reload
381; CHECK-P8-NEXT:    ld r29, -24(r1) # 8-byte Folded Reload
382; CHECK-P8-NEXT:    ld r28, -32(r1) # 8-byte Folded Reload
383; CHECK-P8-NEXT:    mtlr r0
384; CHECK-P8-NEXT:    blr
385entry:
386  %add = fadd fp128 %a, %b
387  %conv = sitofp i32 %i to fp128
388  %add1 = fadd fp128 %add, %conv
389  ret fp128 %add1
390}
391; Function Attrs: norecurse nounwind readnone
392define fastcc fp128 @mixParam_01f(fp128 %a, i32 signext %i, fp128 %b) {
393; CHECK-LABEL: mixParam_01f:
394; CHECK:       # %bb.0: # %entry
395; CHECK-NEXT:    xsaddqp v2, v2, v3
396; CHECK-NEXT:    mtvsrwa v3, r3
397; CHECK-NEXT:    xscvsdqp v3, v3
398; CHECK-NEXT:    xsaddqp v2, v2, v3
399; CHECK-NEXT:    blr
400;
401; CHECK-P8-LABEL: mixParam_01f:
402; CHECK-P8:       # %bb.0: # %entry
403; CHECK-P8-NEXT:    mflr r0
404; CHECK-P8-NEXT:    .cfi_def_cfa_offset 64
405; CHECK-P8-NEXT:    .cfi_offset lr, 16
406; CHECK-P8-NEXT:    .cfi_offset r28, -32
407; CHECK-P8-NEXT:    .cfi_offset r29, -24
408; CHECK-P8-NEXT:    .cfi_offset r30, -16
409; CHECK-P8-NEXT:    std r28, -32(r1) # 8-byte Folded Spill
410; CHECK-P8-NEXT:    std r29, -24(r1) # 8-byte Folded Spill
411; CHECK-P8-NEXT:    std r30, -16(r1) # 8-byte Folded Spill
412; CHECK-P8-NEXT:    std r0, 16(r1)
413; CHECK-P8-NEXT:    stdu r1, -64(r1)
414; CHECK-P8-NEXT:    mr r30, r5
415; CHECK-P8-NEXT:    mr r5, r6
416; CHECK-P8-NEXT:    mr r6, r7
417; CHECK-P8-NEXT:    bl __addkf3
418; CHECK-P8-NEXT:    nop
419; CHECK-P8-NEXT:    mr r29, r3
420; CHECK-P8-NEXT:    mr r3, r30
421; CHECK-P8-NEXT:    mr r28, r4
422; CHECK-P8-NEXT:    bl __floatsikf
423; CHECK-P8-NEXT:    nop
424; CHECK-P8-NEXT:    mr r5, r3
425; CHECK-P8-NEXT:    mr r6, r4
426; CHECK-P8-NEXT:    mr r3, r29
427; CHECK-P8-NEXT:    mr r4, r28
428; CHECK-P8-NEXT:    bl __addkf3
429; CHECK-P8-NEXT:    nop
430; CHECK-P8-NEXT:    addi r1, r1, 64
431; CHECK-P8-NEXT:    ld r0, 16(r1)
432; CHECK-P8-NEXT:    ld r30, -16(r1) # 8-byte Folded Reload
433; CHECK-P8-NEXT:    ld r29, -24(r1) # 8-byte Folded Reload
434; CHECK-P8-NEXT:    ld r28, -32(r1) # 8-byte Folded Reload
435; CHECK-P8-NEXT:    mtlr r0
436; CHECK-P8-NEXT:    blr
437entry:
438  %add = fadd fp128 %a, %b
439  %conv = sitofp i32 %i to fp128
440  %add1 = fadd fp128 %add, %conv
441  ret fp128 %add1
442}
443
444; Function Attrs: norecurse nounwind
445define fp128 @mixParam_02(fp128 %p1, double %p2, i64* nocapture %p3,
446; CHECK-LABEL: mixParam_02:
447; CHECK:       # %bb.0: # %entry
448; CHECK-NEXT:    lwz r3, 96(r1)
449; CHECK-NEXT:    add r4, r7, r9
450; CHECK-NEXT:    xscpsgndp v3, f1, f1
451; CHECK-NEXT:    add r4, r4, r10
452; CHECK-NEXT:    xscvdpqp v3, v3
453; CHECK-NEXT:    add r3, r4, r3
454; CHECK-NEXT:    clrldi r3, r3, 32
455; CHECK-NEXT:    std r3, 0(r6)
456; CHECK-NEXT:    lxv v4, 0(r8)
457; CHECK-NEXT:    xsaddqp v2, v4, v2
458; CHECK-NEXT:    xsaddqp v2, v2, v3
459; CHECK-NEXT:    blr
460;
461; CHECK-P8-LABEL: mixParam_02:
462; CHECK-P8:       # %bb.0: # %entry
463; CHECK-P8-NEXT:    mflr r0
464; CHECK-P8-NEXT:    .cfi_def_cfa_offset 64
465; CHECK-P8-NEXT:    .cfi_offset lr, 16
466; CHECK-P8-NEXT:    .cfi_offset r29, -32
467; CHECK-P8-NEXT:    .cfi_offset r30, -24
468; CHECK-P8-NEXT:    .cfi_offset f31, -8
469; CHECK-P8-NEXT:    std r29, -32(r1) # 8-byte Folded Spill
470; CHECK-P8-NEXT:    std r30, -24(r1) # 8-byte Folded Spill
471; CHECK-P8-NEXT:    stfd f31, -8(r1) # 8-byte Folded Spill
472; CHECK-P8-NEXT:    std r0, 16(r1)
473; CHECK-P8-NEXT:    stdu r1, -64(r1)
474; CHECK-P8-NEXT:    mr r11, r4
475; CHECK-P8-NEXT:    lwz r4, 160(r1)
476; CHECK-P8-NEXT:    add r5, r7, r9
477; CHECK-P8-NEXT:    fmr f31, f1
478; CHECK-P8-NEXT:    add r5, r5, r10
479; CHECK-P8-NEXT:    add r4, r5, r4
480; CHECK-P8-NEXT:    clrldi r4, r4, 32
481; CHECK-P8-NEXT:    std r4, 0(r6)
482; CHECK-P8-NEXT:    mr r6, r3
483; CHECK-P8-NEXT:    ld r5, 0(r8)
484; CHECK-P8-NEXT:    ld r4, 8(r8)
485; CHECK-P8-NEXT:    mr r3, r5
486; CHECK-P8-NEXT:    mr r5, r6
487; CHECK-P8-NEXT:    mr r6, r11
488; CHECK-P8-NEXT:    bl __addkf3
489; CHECK-P8-NEXT:    nop
490; CHECK-P8-NEXT:    fmr f1, f31
491; CHECK-P8-NEXT:    mr r30, r3
492; CHECK-P8-NEXT:    mr r29, r4
493; CHECK-P8-NEXT:    bl __extenddfkf2
494; CHECK-P8-NEXT:    nop
495; CHECK-P8-NEXT:    mr r5, r3
496; CHECK-P8-NEXT:    mr r6, r4
497; CHECK-P8-NEXT:    mr r3, r30
498; CHECK-P8-NEXT:    mr r4, r29
499; CHECK-P8-NEXT:    bl __addkf3
500; CHECK-P8-NEXT:    nop
501; CHECK-P8-NEXT:    addi r1, r1, 64
502; CHECK-P8-NEXT:    ld r0, 16(r1)
503; CHECK-P8-NEXT:    lfd f31, -8(r1) # 8-byte Folded Reload
504; CHECK-P8-NEXT:    ld r30, -24(r1) # 8-byte Folded Reload
505; CHECK-P8-NEXT:    ld r29, -32(r1) # 8-byte Folded Reload
506; CHECK-P8-NEXT:    mtlr r0
507; CHECK-P8-NEXT:    blr
508                          i16 signext %p4, fp128* nocapture readonly %p5,
509                          i32 signext %p6, i8 zeroext %p7, i32 zeroext %p8) {
510entry:
511  %conv = sext i16 %p4 to i32
512  %add = add nsw i32 %conv, %p6
513  %conv1 = zext i8 %p7 to i32
514  %add2 = add nsw i32 %add, %conv1
515  %add3 = add i32 %add2, %p8
516  %conv4 = zext i32 %add3 to i64
517  store i64 %conv4, i64* %p3, align 8
518  %0 = load fp128, fp128* %p5, align 16
519  %add5 = fadd fp128 %0, %p1
520  %conv6 = fpext double %p2 to fp128
521  %add7 = fadd fp128 %add5, %conv6
522  ret fp128 %add7
523}
524
525; Function Attrs: norecurse nounwind
526define fastcc fp128 @mixParam_02f(fp128 %p1, double %p2, i64* nocapture %p3,
527; CHECK-LABEL: mixParam_02f:
528; CHECK:       # %bb.0: # %entry
529; CHECK-NEXT:    add r4, r4, r6
530; CHECK-NEXT:    xscpsgndp v3, f1, f1
531; CHECK-NEXT:    add r4, r4, r7
532; CHECK-NEXT:    xscvdpqp v3, v3
533; CHECK-NEXT:    add r4, r4, r8
534; CHECK-NEXT:    clrldi r4, r4, 32
535; CHECK-NEXT:    std r4, 0(r3)
536; CHECK-NEXT:    lxv v4, 0(r5)
537; CHECK-NEXT:    xsaddqp v2, v4, v2
538; CHECK-NEXT:    xsaddqp v2, v2, v3
539; CHECK-NEXT:    blr
540;
541; CHECK-P8-LABEL: mixParam_02f:
542; CHECK-P8:       # %bb.0: # %entry
543; CHECK-P8-NEXT:    mflr r0
544; CHECK-P8-NEXT:    .cfi_def_cfa_offset 64
545; CHECK-P8-NEXT:    .cfi_offset lr, 16
546; CHECK-P8-NEXT:    .cfi_offset r29, -32
547; CHECK-P8-NEXT:    .cfi_offset r30, -24
548; CHECK-P8-NEXT:    .cfi_offset f31, -8
549; CHECK-P8-NEXT:    std r29, -32(r1) # 8-byte Folded Spill
550; CHECK-P8-NEXT:    std r30, -24(r1) # 8-byte Folded Spill
551; CHECK-P8-NEXT:    stfd f31, -8(r1) # 8-byte Folded Spill
552; CHECK-P8-NEXT:    std r0, 16(r1)
553; CHECK-P8-NEXT:    stdu r1, -64(r1)
554; CHECK-P8-NEXT:    mr r11, r4
555; CHECK-P8-NEXT:    add r4, r6, r8
556; CHECK-P8-NEXT:    mr r6, r3
557; CHECK-P8-NEXT:    fmr f31, f1
558; CHECK-P8-NEXT:    add r4, r4, r9
559; CHECK-P8-NEXT:    add r4, r4, r10
560; CHECK-P8-NEXT:    clrldi r4, r4, 32
561; CHECK-P8-NEXT:    std r4, 0(r5)
562; CHECK-P8-NEXT:    ld r5, 0(r7)
563; CHECK-P8-NEXT:    ld r4, 8(r7)
564; CHECK-P8-NEXT:    mr r3, r5
565; CHECK-P8-NEXT:    mr r5, r6
566; CHECK-P8-NEXT:    mr r6, r11
567; CHECK-P8-NEXT:    bl __addkf3
568; CHECK-P8-NEXT:    nop
569; CHECK-P8-NEXT:    fmr f1, f31
570; CHECK-P8-NEXT:    mr r30, r3
571; CHECK-P8-NEXT:    mr r29, r4
572; CHECK-P8-NEXT:    bl __extenddfkf2
573; CHECK-P8-NEXT:    nop
574; CHECK-P8-NEXT:    mr r5, r3
575; CHECK-P8-NEXT:    mr r6, r4
576; CHECK-P8-NEXT:    mr r3, r30
577; CHECK-P8-NEXT:    mr r4, r29
578; CHECK-P8-NEXT:    bl __addkf3
579; CHECK-P8-NEXT:    nop
580; CHECK-P8-NEXT:    addi r1, r1, 64
581; CHECK-P8-NEXT:    ld r0, 16(r1)
582; CHECK-P8-NEXT:    lfd f31, -8(r1) # 8-byte Folded Reload
583; CHECK-P8-NEXT:    ld r30, -24(r1) # 8-byte Folded Reload
584; CHECK-P8-NEXT:    ld r29, -32(r1) # 8-byte Folded Reload
585; CHECK-P8-NEXT:    mtlr r0
586; CHECK-P8-NEXT:    blr
587                                  i16 signext %p4, fp128* nocapture readonly %p5,
588                                  i32 signext %p6, i8 zeroext %p7, i32 zeroext %p8) {
589entry:
590  %conv = sext i16 %p4 to i32
591  %add = add nsw i32 %conv, %p6
592  %conv1 = zext i8 %p7 to i32
593  %add2 = add nsw i32 %add, %conv1
594  %add3 = add i32 %add2, %p8
595  %conv4 = zext i32 %add3 to i64
596  store i64 %conv4, i64* %p3, align 8
597  %0 = load fp128, fp128* %p5, align 16
598  %add5 = fadd fp128 %0, %p1
599  %conv6 = fpext double %p2 to fp128
600  %add7 = fadd fp128 %add5, %conv6
601  ret fp128 %add7
602}
603
604; Passing a mix of float128 and vector parameters.
605; Function Attrs: norecurse nounwind
606define void @mixParam_03(fp128 %f1, double* nocapture %d1, <4 x i32> %vec1,
607; CHECK-LABEL: mixParam_03:
608; CHECK:       # %bb.0: # %entry
609; CHECK-NEXT:    ld r3, 104(r1)
610; CHECK-NEXT:    stxv v2, 0(r9)
611; CHECK-NEXT:    stxvx v3, 0, r3
612; CHECK-NEXT:    mtvsrwa v3, r10
613; CHECK-NEXT:    lxv v2, 0(r9)
614; CHECK-NEXT:    xscvsdqp v3, v3
615; CHECK-NEXT:    xsaddqp v2, v2, v3
616; CHECK-NEXT:    xscvqpdp v2, v2
617; CHECK-NEXT:    stxsd v2, 0(r5)
618; CHECK-NEXT:    blr
619;
620; CHECK-P8-LABEL: mixParam_03:
621; CHECK-P8:       # %bb.0: # %entry
622; CHECK-P8-NEXT:    mflr r0
623; CHECK-P8-NEXT:    .cfi_def_cfa_offset 64
624; CHECK-P8-NEXT:    .cfi_offset lr, 16
625; CHECK-P8-NEXT:    .cfi_offset r28, -32
626; CHECK-P8-NEXT:    .cfi_offset r29, -24
627; CHECK-P8-NEXT:    .cfi_offset r30, -16
628; CHECK-P8-NEXT:    std r28, -32(r1) # 8-byte Folded Spill
629; CHECK-P8-NEXT:    std r29, -24(r1) # 8-byte Folded Spill
630; CHECK-P8-NEXT:    std r30, -16(r1) # 8-byte Folded Spill
631; CHECK-P8-NEXT:    std r0, 16(r1)
632; CHECK-P8-NEXT:    stdu r1, -64(r1)
633; CHECK-P8-NEXT:    ld r6, 168(r1)
634; CHECK-P8-NEXT:    std r4, 8(r9)
635; CHECK-P8-NEXT:    std r3, 0(r9)
636; CHECK-P8-NEXT:    mr r3, r10
637; CHECK-P8-NEXT:    mr r28, r5
638; CHECK-P8-NEXT:    stvx v2, 0, r6
639; CHECK-P8-NEXT:    ld r30, 0(r9)
640; CHECK-P8-NEXT:    ld r29, 8(r9)
641; CHECK-P8-NEXT:    bl __floatsikf
642; CHECK-P8-NEXT:    nop
643; CHECK-P8-NEXT:    mr r5, r3
644; CHECK-P8-NEXT:    mr r6, r4
645; CHECK-P8-NEXT:    mr r3, r30
646; CHECK-P8-NEXT:    mr r4, r29
647; CHECK-P8-NEXT:    bl __addkf3
648; CHECK-P8-NEXT:    nop
649; CHECK-P8-NEXT:    bl __trunckfdf2
650; CHECK-P8-NEXT:    nop
651; CHECK-P8-NEXT:    stfdx f1, 0, r28
652; CHECK-P8-NEXT:    addi r1, r1, 64
653; CHECK-P8-NEXT:    ld r0, 16(r1)
654; CHECK-P8-NEXT:    ld r30, -16(r1) # 8-byte Folded Reload
655; CHECK-P8-NEXT:    ld r29, -24(r1) # 8-byte Folded Reload
656; CHECK-P8-NEXT:    ld r28, -32(r1) # 8-byte Folded Reload
657; CHECK-P8-NEXT:    mtlr r0
658; CHECK-P8-NEXT:    blr
659                         fp128* nocapture %f2, i32 signext %i1, i8 zeroext %c1,
660                         <4 x i32>* nocapture %vec2) {
661entry:
662  store fp128 %f1, fp128* %f2, align 16
663  store <4 x i32> %vec1, <4 x i32>* %vec2, align 16
664  %0 = load fp128, fp128* %f2, align 16
665  %conv = sitofp i32 %i1 to fp128
666  %add = fadd fp128 %0, %conv
667  %conv1 = fptrunc fp128 %add to double
668  store double %conv1, double* %d1, align 8
669  ret void
670}
671
672; Function Attrs: norecurse nounwind
673define fastcc void @mixParam_03f(fp128 %f1, double* nocapture %d1, <4 x i32> %vec1,
674; CHECK-LABEL: mixParam_03f:
675; CHECK:       # %bb.0: # %entry
676; CHECK-NEXT:    stxv v2, 0(r4)
677; CHECK-NEXT:    stxv v3, 0(r7)
678; CHECK-NEXT:    lxv v2, 0(r4)
679; CHECK-NEXT:    mtvsrwa v3, r5
680; CHECK-NEXT:    xscvsdqp v3, v3
681; CHECK-NEXT:    xsaddqp v2, v2, v3
682; CHECK-NEXT:    xscvqpdp v2, v2
683; CHECK-NEXT:    stxsd v2, 0(r3)
684; CHECK-NEXT:    blr
685;
686; CHECK-P8-LABEL: mixParam_03f:
687; CHECK-P8:       # %bb.0: # %entry
688; CHECK-P8-NEXT:    mflr r0
689; CHECK-P8-NEXT:    .cfi_def_cfa_offset 64
690; CHECK-P8-NEXT:    .cfi_offset lr, 16
691; CHECK-P8-NEXT:    .cfi_offset r28, -32
692; CHECK-P8-NEXT:    .cfi_offset r29, -24
693; CHECK-P8-NEXT:    .cfi_offset r30, -16
694; CHECK-P8-NEXT:    std r28, -32(r1) # 8-byte Folded Spill
695; CHECK-P8-NEXT:    std r29, -24(r1) # 8-byte Folded Spill
696; CHECK-P8-NEXT:    std r30, -16(r1) # 8-byte Folded Spill
697; CHECK-P8-NEXT:    std r0, 16(r1)
698; CHECK-P8-NEXT:    stdu r1, -64(r1)
699; CHECK-P8-NEXT:    std r4, 8(r6)
700; CHECK-P8-NEXT:    std r3, 0(r6)
701; CHECK-P8-NEXT:    mr r3, r7
702; CHECK-P8-NEXT:    mr r28, r5
703; CHECK-P8-NEXT:    stvx v2, 0, r9
704; CHECK-P8-NEXT:    ld r30, 0(r6)
705; CHECK-P8-NEXT:    ld r29, 8(r6)
706; CHECK-P8-NEXT:    bl __floatsikf
707; CHECK-P8-NEXT:    nop
708; CHECK-P8-NEXT:    mr r5, r3
709; CHECK-P8-NEXT:    mr r6, r4
710; CHECK-P8-NEXT:    mr r3, r30
711; CHECK-P8-NEXT:    mr r4, r29
712; CHECK-P8-NEXT:    bl __addkf3
713; CHECK-P8-NEXT:    nop
714; CHECK-P8-NEXT:    bl __trunckfdf2
715; CHECK-P8-NEXT:    nop
716; CHECK-P8-NEXT:    stfdx f1, 0, r28
717; CHECK-P8-NEXT:    addi r1, r1, 64
718; CHECK-P8-NEXT:    ld r0, 16(r1)
719; CHECK-P8-NEXT:    ld r30, -16(r1) # 8-byte Folded Reload
720; CHECK-P8-NEXT:    ld r29, -24(r1) # 8-byte Folded Reload
721; CHECK-P8-NEXT:    ld r28, -32(r1) # 8-byte Folded Reload
722; CHECK-P8-NEXT:    mtlr r0
723; CHECK-P8-NEXT:    blr
724                                 fp128* nocapture %f2, i32 signext %i1, i8 zeroext %c1,
725                                 <4 x i32>* nocapture %vec2) {
726entry:
727  store fp128 %f1, fp128* %f2, align 16
728  store <4 x i32> %vec1, <4 x i32>* %vec2, align 16
729  %0 = load fp128, fp128* %f2, align 16
730  %conv = sitofp i32 %i1 to fp128
731  %add = fadd fp128 %0, %conv
732  %conv1 = fptrunc fp128 %add to double
733  store double %conv1, double* %d1, align 8
734  ret void
735}
736
737; Function Attrs: noinline optnone
738define signext i32 @noopt_call_crash() #0 {
739; CHECK-LABEL: noopt_call_crash:
740; CHECK:       # %bb.0: # %entry
741; CHECK-NEXT:    mflr r0
742; CHECK-NEXT:    std r0, 16(r1)
743; CHECK-NEXT:    stdu r1, -96(r1)
744; CHECK-NEXT:    .cfi_def_cfa_offset 96
745; CHECK-NEXT:    .cfi_offset lr, 16
746; CHECK-NEXT:    bl in
747; CHECK-NEXT:    nop
748; CHECK-NEXT:    bl out
749; CHECK-NEXT:    nop
750; CHECK-NEXT:    li r3, 0
751; CHECK-NEXT:    addi r1, r1, 96
752; CHECK-NEXT:    ld r0, 16(r1)
753; CHECK-NEXT:    mtlr r0
754; CHECK-NEXT:    blr
755;
756; CHECK-P8-LABEL: noopt_call_crash:
757; CHECK-P8:       # %bb.0: # %entry
758; CHECK-P8-NEXT:    mflr r0
759; CHECK-P8-NEXT:    std r0, 16(r1)
760; CHECK-P8-NEXT:    stdu r1, -32(r1)
761; CHECK-P8-NEXT:    .cfi_def_cfa_offset 32
762; CHECK-P8-NEXT:    .cfi_offset lr, 16
763; CHECK-P8-NEXT:    bl in
764; CHECK-P8-NEXT:    nop
765; CHECK-P8-NEXT:    bl out
766; CHECK-P8-NEXT:    nop
767; CHECK-P8-NEXT:    li r3, 0
768; CHECK-P8-NEXT:    addi r1, r1, 32
769; CHECK-P8-NEXT:    ld r0, 16(r1)
770; CHECK-P8-NEXT:    mtlr r0
771; CHECK-P8-NEXT:    blr
772entry:
773  %call = call fp128 @in()
774  call void @out(fp128 %call)
775  ret i32 0
776}
777
778declare void @out(fp128)
779declare fp128 @in()
780
781attributes #0 = { noinline optnone }
782