blob: 50177e5f41bf40f8ff6770157cf725c2c6766e76 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test copysign operations.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5declare float @copysignf(float, float) readnone
6declare double @copysign(double, double) readnone
7; FIXME: not really the correct prototype for SystemZ.
8declare fp128 @copysignl(fp128, fp128) readnone
9
10; Test f32 copies in which the sign comes from an f32.
11define float @f1(float %a, float %b) {
Stephen Lind24ab202013-07-14 06:24:09 +000012; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000013; CHECK-NOT: %f2
14; CHECK: cpsdr %f0, %f0, %f2
15; CHECK: br %r14
16 %res = call float @copysignf(float %a, float %b) readnone
17 ret float %res
18}
19
20; Test f32 copies in which the sign comes from an f64.
21define float @f2(float %a, double %bd) {
Stephen Lind24ab202013-07-14 06:24:09 +000022; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000023; CHECK-NOT: %f2
24; CHECK: cpsdr %f0, %f0, %f2
25; CHECK: br %r14
26 %b = fptrunc double %bd to float
27 %res = call float @copysignf(float %a, float %b) readnone
28 ret float %res
29}
30
31; Test f32 copies in which the sign comes from an f128.
32define float @f3(float %a, fp128 *%bptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000033; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000034; CHECK: ld [[BHIGH:%f[0-7]]], 0(%r2)
35; CHECK: ld [[BLOW:%f[0-7]]], 8(%r2)
36; CHECK: cpsdr %f0, %f0, [[BHIGH]]
37; CHECK: br %r14
38 %bl = load volatile fp128 *%bptr
39 %b = fptrunc fp128 %bl to float
40 %res = call float @copysignf(float %a, float %b) readnone
41 ret float %res
42}
43
44; Test f64 copies in which the sign comes from an f32.
45define double @f4(double %a, float %bf) {
Stephen Lind24ab202013-07-14 06:24:09 +000046; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000047; CHECK-NOT: %f2
48; CHECK: cpsdr %f0, %f0, %f2
49; CHECK: br %r14
50 %b = fpext float %bf to double
51 %res = call double @copysign(double %a, double %b) readnone
52 ret double %res
53}
54
55; Test f64 copies in which the sign comes from an f64.
56define double @f5(double %a, double %b) {
Stephen Lind24ab202013-07-14 06:24:09 +000057; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000058; CHECK-NOT: %f2
59; CHECK: cpsdr %f0, %f0, %f2
60; CHECK: br %r14
61 %res = call double @copysign(double %a, double %b) readnone
62 ret double %res
63}
64
65; Test f64 copies in which the sign comes from an f128.
66define double @f6(double %a, fp128 *%bptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000067; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000068; CHECK: ld [[BHIGH:%f[0-7]]], 0(%r2)
69; CHECK: ld [[BLOW:%f[0-7]]], 8(%r2)
70; CHECK: cpsdr %f0, %f0, [[BHIGH]]
71; CHECK: br %r14
72 %bl = load volatile fp128 *%bptr
73 %b = fptrunc fp128 %bl to double
74 %res = call double @copysign(double %a, double %b) readnone
75 ret double %res
76}
77
78; Test f128 copies in which the sign comes from an f32. We shouldn't
79; need any register shuffling here; %a should be tied to %c, with CPSDR
80; just changing the high register.
81define void @f7(fp128 *%cptr, fp128 *%aptr, float %bf) {
Stephen Lind24ab202013-07-14 06:24:09 +000082; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000083; CHECK: ld [[AHIGH:%f[0-7]]], 0(%r3)
84; CHECK: ld [[ALOW:%f[0-7]]], 8(%r3)
85; CHECK: cpsdr [[AHIGH]], [[AHIGH]], %f0
86; CHECK: std [[AHIGH]], 0(%r2)
87; CHECK: std [[ALOW]], 8(%r2)
88; CHECK: br %r14
89 %a = load volatile fp128 *%aptr
90 %b = fpext float %bf to fp128
91 %c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
92 store fp128 %c, fp128 *%cptr
93 ret void
94}
95
96; As above, but the sign comes from an f64.
97define void @f8(fp128 *%cptr, fp128 *%aptr, double %bd) {
Stephen Lind24ab202013-07-14 06:24:09 +000098; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000099; CHECK: ld [[AHIGH:%f[0-7]]], 0(%r3)
100; CHECK: ld [[ALOW:%f[0-7]]], 8(%r3)
101; CHECK: cpsdr [[AHIGH]], [[AHIGH]], %f0
102; CHECK: std [[AHIGH]], 0(%r2)
103; CHECK: std [[ALOW]], 8(%r2)
104; CHECK: br %r14
105 %a = load volatile fp128 *%aptr
106 %b = fpext double %bd to fp128
107 %c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
108 store fp128 %c, fp128 *%cptr
109 ret void
110}
111
112; As above, but the sign comes from an f128. Don't require the low part
113; of %b to be loaded, since it isn't used.
114define void @f9(fp128 *%cptr, fp128 *%aptr, fp128 *%bptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000115; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000116; CHECK: ld [[AHIGH:%f[0-7]]], 0(%r3)
117; CHECK: ld [[ALOW:%f[0-7]]], 8(%r3)
118; CHECK: ld [[BHIGH:%f[0-7]]], 0(%r4)
119; CHECK: cpsdr [[AHIGH]], [[AHIGH]], [[BHIGH]]
120; CHECK: std [[AHIGH]], 0(%r2)
121; CHECK: std [[ALOW]], 8(%r2)
122; CHECK: br %r14
123 %a = load volatile fp128 *%aptr
124 %b = load volatile fp128 *%bptr
125 %c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
126 store fp128 %c, fp128 *%cptr
127 ret void
128}