1; Test strict extensions of f64 to f128.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5declare fp128 @llvm.experimental.constrained.fpext.f128.f64(double, metadata)
6
7; Check register extension.
8define void @f1(fp128 *%dst, double %val) #0 {
9; CHECK-LABEL: f1:
10; CHECK: lxdbr %f0, %f0
11; CHECK: std %f0, 0(%r2)
12; CHECK: std %f2, 8(%r2)
13; CHECK: br %r14
14  %res = call fp128 @llvm.experimental.constrained.fpext.f128.f64(double %val,
15                                               metadata !"fpexcept.strict") #0
16  store fp128 %res, fp128 *%dst
17  ret void
18}
19
20; Check the low end of the LXDB range.
21define void @f2(fp128 *%dst, double *%ptr) #0 {
22; CHECK-LABEL: f2:
23; CHECK: lxdb %f0, 0(%r3)
24; CHECK: std %f0, 0(%r2)
25; CHECK: std %f2, 8(%r2)
26; CHECK: br %r14
27  %val = load double, double *%ptr
28  %res = call fp128 @llvm.experimental.constrained.fpext.f128.f64(double %val,
29                                               metadata !"fpexcept.strict") #0
30  store fp128 %res, fp128 *%dst
31  ret void
32}
33
34; Check the high end of the aligned LXDB range.
35define void @f3(fp128 *%dst, double *%base) #0 {
36; CHECK-LABEL: f3:
37; CHECK: lxdb %f0, 4088(%r3)
38; CHECK: std %f0, 0(%r2)
39; CHECK: std %f2, 8(%r2)
40; CHECK: br %r14
41  %ptr = getelementptr double, double *%base, i64 511
42  %val = load double, double *%ptr
43  %res = call fp128 @llvm.experimental.constrained.fpext.f128.f64(double %val,
44                                               metadata !"fpexcept.strict") #0
45  store fp128 %res, fp128 *%dst
46  ret void
47}
48
49; Check the next doubleword up, which needs separate address logic.
50; Other sequences besides this one would be OK.
51define void @f4(fp128 *%dst, double *%base) #0 {
52; CHECK-LABEL: f4:
53; CHECK: aghi %r3, 4096
54; CHECK: lxdb %f0, 0(%r3)
55; CHECK: std %f0, 0(%r2)
56; CHECK: std %f2, 8(%r2)
57; CHECK: br %r14
58  %ptr = getelementptr double, double *%base, i64 512
59  %val = load double, double *%ptr
60  %res = call fp128 @llvm.experimental.constrained.fpext.f128.f64(double %val,
61                                               metadata !"fpexcept.strict") #0
62  store fp128 %res, fp128 *%dst
63  ret void
64}
65
66; Check negative displacements, which also need separate address logic.
67define void @f5(fp128 *%dst, double *%base) #0 {
68; CHECK-LABEL: f5:
69; CHECK: aghi %r3, -8
70; CHECK: lxdb %f0, 0(%r3)
71; CHECK: std %f0, 0(%r2)
72; CHECK: std %f2, 8(%r2)
73; CHECK: br %r14
74  %ptr = getelementptr double, double *%base, i64 -1
75  %val = load double, double *%ptr
76  %res = call fp128 @llvm.experimental.constrained.fpext.f128.f64(double %val,
77                                               metadata !"fpexcept.strict") #0
78  store fp128 %res, fp128 *%dst
79  ret void
80}
81
82; Check that LXDB allows indices.
83define void @f6(fp128 *%dst, double *%base, i64 %index) #0 {
84; CHECK-LABEL: f6:
85; CHECK: sllg %r1, %r4, 3
86; CHECK: lxdb %f0, 800(%r1,%r3)
87; CHECK: std %f0, 0(%r2)
88; CHECK: std %f2, 8(%r2)
89; CHECK: br %r14
90  %ptr1 = getelementptr double, double *%base, i64 %index
91  %ptr2 = getelementptr double, double *%ptr1, i64 100
92  %val = load double, double *%ptr2
93  %res = call fp128 @llvm.experimental.constrained.fpext.f128.f64(double %val,
94                                               metadata !"fpexcept.strict") #0
95  store fp128 %res, fp128 *%dst
96  ret void
97}
98
99attributes #0 = { strictfp }
100