1 ; Test strict floating-point truncations.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 \
4 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-SCALAR %s
5 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 \
6 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-VECTOR %s
8 declare float @llvm.experimental.constrained.fptrunc.f32.f64(double, metadata, metadata)
9 declare float @llvm.experimental.constrained.fptrunc.f32.f128(fp128, metadata, metadata)
10 declare double @llvm.experimental.constrained.fptrunc.f64.f128(fp128, metadata, metadata)
12 declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata)
13 declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
16 define float @f1(double %d1, double %d2) #0 {
18 ; CHECK-SCALAR: ledbr %f0, %f2
19 ; CHECK-VECTOR: ledbra %f0, 0, %f2, 0
21 %res = call float @llvm.experimental.constrained.fptrunc.f32.f64(
23 metadata !"round.dynamic",
24 metadata !"fpexcept.strict") #0
29 define float @f2(fp128 *%ptr) #0 {
31 ; CHECK: lexbr %f0, %f0
33 %val = load fp128, fp128 *%ptr
34 %res = call float @llvm.experimental.constrained.fptrunc.f32.f128(
36 metadata !"round.dynamic",
37 metadata !"fpexcept.strict") #0
41 ; Make sure that we don't use %f0 as the destination of LEXBR when %f2
43 define void @f3(float *%dst, fp128 *%ptr, float %d1, float %d2) #0 {
45 ; CHECK: lexbr %f1, %f1
46 ; CHECK: aebr %f1, %f2
47 ; CHECK: ste %f1, 0(%r2)
49 %val = load fp128, fp128 *%ptr
50 %conv = call float @llvm.experimental.constrained.fptrunc.f32.f128(
52 metadata !"round.dynamic",
53 metadata !"fpexcept.strict") #0
54 %res = call float @llvm.experimental.constrained.fadd.f32(
55 float %conv, float %d2,
56 metadata !"round.dynamic",
57 metadata !"fpexcept.strict") #0
58 store float %res, float *%dst
63 define double @f4(fp128 *%ptr) #0 {
65 ; CHECK: ldxbr %f0, %f0
67 %val = load fp128, fp128 *%ptr
68 %res = call double @llvm.experimental.constrained.fptrunc.f64.f128(
70 metadata !"round.dynamic",
71 metadata !"fpexcept.strict") #0
75 ; Like f3, but for f128->f64.
76 define void @f5(double *%dst, fp128 *%ptr, double %d1, double %d2) #0 {
78 ; CHECK: ldxbr %f1, %f1
79 ; CHECK-SCALAR: adbr %f1, %f2
80 ; CHECK-SCALAR: std %f1, 0(%r2)
81 ; CHECK-VECTOR: wfadb [[REG:%f[0-9]+]], %f1, %f2
82 ; CHECK-VECTOR: std [[REG]], 0(%r2)
84 %val = load fp128, fp128 *%ptr
85 %conv = call double @llvm.experimental.constrained.fptrunc.f64.f128(
87 metadata !"round.dynamic",
88 metadata !"fpexcept.strict") #0
89 %res = call double @llvm.experimental.constrained.fadd.f64(
90 double %conv, double %d2,
91 metadata !"round.dynamic",
92 metadata !"fpexcept.strict") #0
93 store double %res, double *%dst
97 attributes #0 = { strictfp }