1 ; RUN: llc -mcpu=pwr7 -mattr=+altivec -mattr=-vsx < %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-n32:64"
4 target triple = "powerpc64le-unknown-linux-gnu"
6 @g = common global ppc_fp128 0xM00000000000000000000000000000000, align 16
8 define void @callee(ppc_fp128 %x) {
10 %x.addr = alloca ppc_fp128, align 16
11 store ppc_fp128 %x, ppc_fp128* %x.addr, align 16
12 %0 = load ppc_fp128, ppc_fp128* %x.addr, align 16
13 store ppc_fp128 %0, ppc_fp128* @g, align 16
17 ; CHECK: ld [[REG:[0-9]+]], .LC
18 ; CHECK: stfd 2, 8([[REG]])
19 ; CHECK: stfd 1, 0([[REG]])
22 define void @caller() {
24 %0 = load ppc_fp128, ppc_fp128* @g, align 16
25 call void @test(ppc_fp128 %0)
29 ; CHECK: ld [[REG:[0-9]+]], .LC
30 ; CHECK: lfd 2, 8([[REG]])
31 ; CHECK: lfd 1, 0([[REG]])
34 declare void @test(ppc_fp128)
36 define void @caller_const() {
38 call void @test(ppc_fp128 0xM3FF00000000000000000000000000000)
41 ; CHECK: .LCPI[[LC:[0-9]+]]_0:
42 ; CHECK: .long 1065353216
43 ; CHECK: .LCPI[[LC]]_1:
45 ; CHECK: @caller_const
46 ; CHECK: addi [[REG0:[0-9]+]], {{[0-9]+}}, .LCPI[[LC]]_0
47 ; CHECK: addi [[REG1:[0-9]+]], {{[0-9]+}}, .LCPI[[LC]]_1
48 ; CHECK: lfs 1, 0([[REG0]])
49 ; CHECK: lfs 2, 0([[REG1]])
52 define ppc_fp128 @result() {
54 %0 = load ppc_fp128, ppc_fp128* @g, align 16
58 ; CHECK: ld [[REG:[0-9]+]], .LC
59 ; CHECK: lfd 1, 0([[REG]])
60 ; CHECK: lfd 2, 8([[REG]])
63 define void @use_result() {
65 %call = tail call ppc_fp128 @test_result() #3
66 store ppc_fp128 %call, ppc_fp128* @g, align 16
70 ; CHECK: bl test_result
71 ; CHECK: ld [[REG:[0-9]+]], .LC
72 ; CHECK: stfd 2, 8([[REG]])
73 ; CHECK: stfd 1, 0([[REG]])
76 declare ppc_fp128 @test_result()
78 define void @caller_result() {
80 %call = tail call ppc_fp128 @test_result()
81 tail call void @test(ppc_fp128 %call)
84 ; CHECK: @caller_result
85 ; CHECK: bl test_result
90 define i128 @convert_from(ppc_fp128 %x) {
92 %0 = bitcast ppc_fp128 %x to i128
95 ; CHECK: @convert_from
96 ; CHECK: stfd 1, [[OFF1:.*]](1)
97 ; CHECK: stfd 2, [[OFF2:.*]](1)
98 ; CHECK: ld 3, [[OFF1]](1)
99 ; CHECK: ld 4, [[OFF2]](1)
102 define ppc_fp128 @convert_to(i128 %x) {
104 %0 = bitcast i128 %x to ppc_fp128
108 ; CHECK: std 3, [[OFF1:.*]](1)
109 ; CHECK: std 4, [[OFF2:.*]](1)
110 ; CHECK: lfd 1, [[OFF1]](1)
111 ; CHECK: lfd 2, [[OFF2]](1)
114 define ppc_fp128 @convert_to2(i128 %x) {
116 %shl = shl i128 %x, 1
117 %0 = bitcast i128 %shl to ppc_fp128
122 ; CHECK: std 3, [[OFF1:.*]](1)
123 ; CHECK: std 4, [[OFF2:.*]](1)
124 ; CHECK: lfd 1, [[OFF1]](1)
125 ; CHECK: lfd 2, [[OFF2]](1)
128 define double @convert_vector(<4 x i32> %x) {
130 %cast = bitcast <4 x i32> %x to ppc_fp128
131 %conv = fptrunc ppc_fp128 %cast to double
134 ; CHECK: @convert_vector
135 ; CHECK: addi [[REG:[0-9]+]], 1, [[OFF:.*]]
136 ; CHECK: stvx 2, 0, [[REG]]
137 ; CHECK: lfd 1, [[OFF]](1)
140 declare void @llvm.va_start(i8*)
142 define double @vararg(i32 %a, ...) {
144 %va = alloca i8*, align 8
145 %va1 = bitcast i8** %va to i8*
146 call void @llvm.va_start(i8* %va1)
147 %arg = va_arg i8** %va, ppc_fp128
148 %conv = fptrunc ppc_fp128 %arg to double
152 ; CHECK: lfd 1, 0({{[0-9]+}})