1; Test f128 floating-point strict conversion to/from integers on z14.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
4
5declare fp128 @llvm.experimental.constrained.sitofp.f128.i32(i32, metadata, metadata)
6declare fp128 @llvm.experimental.constrained.sitofp.f128.i64(i64, metadata, metadata)
7
8declare fp128 @llvm.experimental.constrained.uitofp.f128.i32(i32, metadata, metadata)
9declare fp128 @llvm.experimental.constrained.uitofp.f128.i64(i64, metadata, metadata)
10
11declare i32 @llvm.experimental.constrained.fptosi.i32.f128(fp128, metadata)
12declare i64 @llvm.experimental.constrained.fptosi.i64.f128(fp128, metadata)
13
14declare i32 @llvm.experimental.constrained.fptoui.i32.f128(fp128, metadata)
15declare i64 @llvm.experimental.constrained.fptoui.i64.f128(fp128, metadata)
16
17; Test signed i32->f128.
18define void @f1(i32 %i, fp128 *%dst) #0 {
19; CHECK-LABEL: f1:
20; CHECK: cxfbr %f0, %r2
21; CHECK: vmrhg %v0, %v0, %v2
22; CHECK: vst %v0, 0(%r3)
23; CHECK: br %r14
24  %conv = call fp128 @llvm.experimental.constrained.sitofp.f128.i32(i32 %i,
25                                               metadata !"round.dynamic",
26                                               metadata !"fpexcept.strict") #0
27  store fp128 %conv, fp128 *%dst
28  ret void
29}
30
31; Test signed i64->f128.
32define void @f2(i64 %i, fp128 *%dst) #0 {
33; CHECK-LABEL: f2:
34; CHECK: cxgbr %f0, %r2
35; CHECK: vmrhg %v0, %v0, %v2
36; CHECK: vst %v0, 0(%r3)
37; CHECK: br %r14
38  %conv = call fp128 @llvm.experimental.constrained.sitofp.f128.i64(i64 %i,
39                                               metadata !"round.dynamic",
40                                               metadata !"fpexcept.strict") #0
41  store fp128 %conv, fp128 *%dst
42  ret void
43}
44
45; Test unsigned i32->f128.
46define void @f3(i32 %i, fp128 *%dst) #0 {
47; CHECK-LABEL: f3:
48; CHECK: cxlfbr %f0, 0, %r2, 0
49; CHECK: vmrhg %v0, %v0, %v2
50; CHECK: vst %v0, 0(%r3)
51; CHECK: br %r14
52  %conv = call fp128 @llvm.experimental.constrained.uitofp.f128.i32(i32 %i,
53                                               metadata !"round.dynamic",
54                                               metadata !"fpexcept.strict") #0
55  store fp128 %conv, fp128 *%dst
56  ret void
57}
58
59; Test unsigned i64->f128.
60define void @f4(i64 %i, fp128 *%dst) #0 {
61; CHECK-LABEL: f4:
62; CHECK: cxlgbr %f0, 0, %r2, 0
63; CHECK: vmrhg %v0, %v0, %v2
64; CHECK: vst %v0, 0(%r3)
65; CHECK: br %r14
66  %conv = call fp128 @llvm.experimental.constrained.uitofp.f128.i64(i64 %i,
67                                               metadata !"round.dynamic",
68                                               metadata !"fpexcept.strict") #0
69  store fp128 %conv, fp128 *%dst
70  ret void
71}
72
73; Test signed f128->i32.
74define i32 @f5(fp128 *%src) #0 {
75; CHECK-LABEL: f5:
76; CHECK: vl %v0, 0(%r2)
77; CHECK: vrepg %v2, %v0, 1
78; CHECK: cfxbr %r2, 5, %f0
79; CHECK: br %r14
80  %f = load fp128, fp128 *%src
81  %conv = call i32 @llvm.experimental.constrained.fptosi.i32.f128(fp128 %f,
82                                               metadata !"fpexcept.strict") #0
83  ret i32 %conv
84}
85
86; Test signed f128->i64.
87define i64 @f6(fp128 *%src) #0 {
88; CHECK-LABEL: f6:
89; CHECK: vl %v0, 0(%r2)
90; CHECK: vrepg %v2, %v0, 1
91; CHECK: cgxbr %r2, 5, %f0
92; CHECK: br %r14
93  %f = load fp128, fp128 *%src
94  %conv = call i64 @llvm.experimental.constrained.fptosi.i64.f128(fp128 %f,
95                                               metadata !"fpexcept.strict") #0
96  ret i64 %conv
97}
98
99; Test unsigned f128->i32.
100define i32 @f7(fp128 *%src) #0 {
101; CHECK-LABEL: f7:
102; CHECK: vl %v0, 0(%r2)
103; CHECK: vrepg %v2, %v0, 1
104; CHECK: clfxbr %r2, 5, %f0, 0
105; CHECK: br %r14
106  %f = load fp128, fp128 *%src
107  %conv = call i32 @llvm.experimental.constrained.fptoui.i32.f128(fp128 %f,
108                                               metadata !"fpexcept.strict") #0
109  ret i32 %conv
110}
111
112; Test unsigned f128->i64.
113define i64 @f8(fp128 *%src) #0 {
114; CHECK-LABEL: f8:
115; CHECK: vl %v0, 0(%r2)
116; CHECK: vrepg %v2, %v0, 1
117; CHECK: clgxbr %r2, 5, %f0, 0
118; CHECK: br %r14
119  %f = load fp128, fp128 *%src
120  %conv = call i64 @llvm.experimental.constrained.fptoui.i64.f128(fp128 %f,
121                                               metadata !"fpexcept.strict") #0
122  ret i64 %conv
123}
124
125attributes #0 = { strictfp }
126