blob: 931688538418f84d4aabc7328183b8ce15d80e6c [file] [log] [blame]
Ehsan Amiria538b0f2016-08-03 18:17:35 +00001; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=+altivec -mattr=-vsx < %s | FileCheck %s
Ulrich Weigandf236bb12014-07-03 15:06:47 +00002
3target datalayout = "e-m:e-i64:64-n32:64"
4target triple = "powerpc64le-unknown-linux-gnu"
5
6@g = common global ppc_fp128 0xM00000000000000000000000000000000, align 16
7
8define void @callee(ppc_fp128 %x) {
9entry:
10 %x.addr = alloca ppc_fp128, align 16
11 store ppc_fp128 %x, ppc_fp128* %x.addr, align 16
David Blaikiea79ac142015-02-27 21:17:42 +000012 %0 = load ppc_fp128, ppc_fp128* %x.addr, align 16
Ulrich Weigandf236bb12014-07-03 15:06:47 +000013 store ppc_fp128 %0, ppc_fp128* @g, align 16
14 ret void
15}
16; CHECK: @callee
17; CHECK: ld [[REG:[0-9]+]], .LC
18; CHECK: stfd 2, 8([[REG]])
19; CHECK: stfd 1, 0([[REG]])
20; CHECK: blr
21
22define void @caller() {
23entry:
David Blaikiea79ac142015-02-27 21:17:42 +000024 %0 = load ppc_fp128, ppc_fp128* @g, align 16
Ulrich Weigandf236bb12014-07-03 15:06:47 +000025 call void @test(ppc_fp128 %0)
26 ret void
27}
28; CHECK: @caller
29; CHECK: ld [[REG:[0-9]+]], .LC
30; CHECK: lfd 2, 8([[REG]])
31; CHECK: lfd 1, 0([[REG]])
32; CHECK: bl test
33
34declare void @test(ppc_fp128)
35
36define void @caller_const() {
37entry:
38 call void @test(ppc_fp128 0xM3FF00000000000000000000000000000)
39 ret void
40}
41; CHECK: .LCPI[[LC:[0-9]+]]_0:
42; CHECK: .long 1065353216
43; CHECK: .LCPI[[LC]]_1:
44; CHECK: .long 0
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]])
50; CHECK: bl test
51
52define ppc_fp128 @result() {
53entry:
David Blaikiea79ac142015-02-27 21:17:42 +000054 %0 = load ppc_fp128, ppc_fp128* @g, align 16
Ulrich Weigandf236bb12014-07-03 15:06:47 +000055 ret ppc_fp128 %0
56}
57; CHECK: @result
58; CHECK: ld [[REG:[0-9]+]], .LC
59; CHECK: lfd 1, 0([[REG]])
60; CHECK: lfd 2, 8([[REG]])
61; CHECK: blr
62
63define void @use_result() {
64entry:
65 %call = tail call ppc_fp128 @test_result() #3
66 store ppc_fp128 %call, ppc_fp128* @g, align 16
67 ret void
68}
69; CHECK: @use_result
70; CHECK: bl test_result
71; CHECK: ld [[REG:[0-9]+]], .LC
72; CHECK: stfd 2, 8([[REG]])
73; CHECK: stfd 1, 0([[REG]])
74; CHECK: blr
75
76declare ppc_fp128 @test_result()
77
78define void @caller_result() {
79entry:
80 %call = tail call ppc_fp128 @test_result()
81 tail call void @test(ppc_fp128 %call)
82 ret void
83}
84; CHECK: @caller_result
85; CHECK: bl test_result
86; CHECK-NEXT: nop
87; CHECK-NEXT: bl test
88; CHECK-NEXT: nop
89
90define i128 @convert_from(ppc_fp128 %x) {
91entry:
92 %0 = bitcast ppc_fp128 %x to i128
93 ret i128 %0
94}
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)
100; CHECK: blr
101
102define ppc_fp128 @convert_to(i128 %x) {
103entry:
104 %0 = bitcast i128 %x to ppc_fp128
105 ret ppc_fp128 %0
106}
David Majnemerbff6b582016-01-28 18:59:04 +0000107; CHECK: convert_to:
Ulrich Weigandf236bb12014-07-03 15:06:47 +0000108; CHECK: std 3, [[OFF1:.*]](1)
109; CHECK: std 4, [[OFF2:.*]](1)
David Majnemerbff6b582016-01-28 18:59:04 +0000110; CHECK: ori 2, 2, 0
Ulrich Weigandf236bb12014-07-03 15:06:47 +0000111; CHECK: lfd 1, [[OFF1]](1)
112; CHECK: lfd 2, [[OFF2]](1)
113; CHECK: blr
114
115define ppc_fp128 @convert_to2(i128 %x) {
116entry:
117 %shl = shl i128 %x, 1
118 %0 = bitcast i128 %shl to ppc_fp128
119 ret ppc_fp128 %0
120}
121
David Majnemerbff6b582016-01-28 18:59:04 +0000122; CHECK: convert_to2:
Ulrich Weigandf236bb12014-07-03 15:06:47 +0000123; CHECK: std 3, [[OFF1:.*]](1)
David Majnemerbff6b582016-01-28 18:59:04 +0000124; CHECK: std 5, [[OFF2:.*]](1)
125; CHECK: ori 2, 2, 0
Ulrich Weigandf236bb12014-07-03 15:06:47 +0000126; CHECK: lfd 1, [[OFF1]](1)
127; CHECK: lfd 2, [[OFF2]](1)
128; CHECK: blr
129
130define double @convert_vector(<4 x i32> %x) {
131entry:
132 %cast = bitcast <4 x i32> %x to ppc_fp128
133 %conv = fptrunc ppc_fp128 %cast to double
134 ret double %conv
135}
136; CHECK: @convert_vector
137; CHECK: addi [[REG:[0-9]+]], 1, [[OFF:.*]]
138; CHECK: stvx 2, 0, [[REG]]
139; CHECK: lfd 1, [[OFF]](1)
140; CHECK: blr
141
142declare void @llvm.va_start(i8*)
143
144define double @vararg(i32 %a, ...) {
145entry:
146 %va = alloca i8*, align 8
147 %va1 = bitcast i8** %va to i8*
148 call void @llvm.va_start(i8* %va1)
149 %arg = va_arg i8** %va, ppc_fp128
150 %conv = fptrunc ppc_fp128 %arg to double
151 ret double %conv
152}
153; CHECK: @vararg
154; CHECK: lfd 1, 0({{[0-9]+}})
155; CHECK: blr
156