1 ; Test copysign operations.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 declare float @copysignf(float, float) readnone
6 declare double @copysign(double, double) readnone
7 ; FIXME: not really the correct prototype for SystemZ.
8 declare fp128 @copysignl(fp128, fp128) readnone
10 ; Test f32 copies in which the sign comes from an f32.
11 define float @f1(float %a, float %b) {
14 ; CHECK: cpsdr %f0, %f2, %f0
16 %res = call float @copysignf(float %a, float %b) readnone
20 ; Test f32 copies in which the sign comes from an f64.
21 define float @f2(float %a, double %bd) {
24 ; CHECK: cpsdr %f0, %f2, %f0
26 %b = fptrunc double %bd to float
27 %res = call float @copysignf(float %a, float %b) readnone
31 ; Test f32 copies in which the sign comes from an f128.
32 define float @f3(float %a, ptr %bptr) {
34 ; CHECK: ld [[BHIGH:%f[0-7]]], 0(%r2)
35 ; CHECK: ld [[BLOW:%f[0-7]]], 8(%r2)
36 ; CHECK: cpsdr %f0, [[BHIGH]], %f0
38 %bl = load volatile fp128, ptr %bptr
39 %b = fptrunc fp128 %bl to float
40 %res = call float @copysignf(float %a, float %b) readnone
44 ; Test f64 copies in which the sign comes from an f32.
45 define double @f4(double %a, float %bf) {
48 ; CHECK: cpsdr %f0, %f2, %f0
50 %b = fpext float %bf to double
51 %res = call double @copysign(double %a, double %b) readnone
55 ; Test f64 copies in which the sign comes from an f64.
56 define double @f5(double %a, double %b) {
59 ; CHECK: cpsdr %f0, %f2, %f0
61 %res = call double @copysign(double %a, double %b) readnone
65 ; Test f64 copies in which the sign comes from an f128.
66 define double @f6(double %a, ptr %bptr) {
68 ; CHECK: ld [[BHIGH:%f[0-7]]], 0(%r2)
69 ; CHECK: ld [[BLOW:%f[0-7]]], 8(%r2)
70 ; CHECK: cpsdr %f0, [[BHIGH]], %f0
72 %bl = load volatile fp128, ptr %bptr
73 %b = fptrunc fp128 %bl to double
74 %res = call double @copysign(double %a, double %b) readnone
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.
81 define void @f7(ptr %cptr, ptr %aptr, float %bf) {
83 ; CHECK: ld [[AHIGH:%f[0-7]]], 0(%r3)
84 ; CHECK: ld [[ALOW:%f[0-7]]], 8(%r3)
85 ; CHECK: cpsdr [[AHIGH]], %f0, [[AHIGH]]
86 ; CHECK: std [[AHIGH]], 0(%r2)
87 ; CHECK: std [[ALOW]], 8(%r2)
89 %a = load volatile fp128, ptr %aptr
90 %b = fpext float %bf to fp128
91 %c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
92 store fp128 %c, ptr %cptr
96 ; As above, but the sign comes from an f64.
97 define void @f8(ptr %cptr, ptr %aptr, double %bd) {
99 ; CHECK: ld [[AHIGH:%f[0-7]]], 0(%r3)
100 ; CHECK: ld [[ALOW:%f[0-7]]], 8(%r3)
101 ; CHECK: cpsdr [[AHIGH]], %f0, [[AHIGH]]
102 ; CHECK: std [[AHIGH]], 0(%r2)
103 ; CHECK: std [[ALOW]], 8(%r2)
105 %a = load volatile fp128, ptr %aptr
106 %b = fpext double %bd to fp128
107 %c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
108 store fp128 %c, ptr %cptr
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.
114 define void @f9(ptr %cptr, ptr %aptr, ptr %bptr) {
116 ; 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]], [[BHIGH]], [[AHIGH]]
120 ; CHECK: std [[AHIGH]], 0(%r2)
121 ; CHECK: std [[ALOW]], 8(%r2)
123 %a = load volatile fp128, ptr %aptr
124 %b = load volatile fp128, ptr %bptr
125 %c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
126 store fp128 %c, ptr %cptr