2013-05-07 00:17:29 +08:00
|
|
|
; Test copysign operations.
|
|
|
|
;
|
|
|
|
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
|
|
|
|
|
|
|
|
declare float @copysignf(float, float) readnone
|
|
|
|
declare double @copysign(double, double) readnone
|
|
|
|
; FIXME: not really the correct prototype for SystemZ.
|
|
|
|
declare fp128 @copysignl(fp128, fp128) readnone
|
|
|
|
|
|
|
|
; Test f32 copies in which the sign comes from an f32.
|
|
|
|
define float @f1(float %a, float %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f1:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK-NOT: %f2
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr %f0, %f2, %f0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
|
|
|
%res = call float @copysignf(float %a, float %b) readnone
|
|
|
|
ret float %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f32 copies in which the sign comes from an f64.
|
|
|
|
define float @f2(float %a, double %bd) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f2:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK-NOT: %f2
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr %f0, %f2, %f0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
|
|
|
%b = fptrunc double %bd to float
|
|
|
|
%res = call float @copysignf(float %a, float %b) readnone
|
|
|
|
ret float %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f32 copies in which the sign comes from an f128.
|
|
|
|
define float @f3(float %a, fp128 *%bptr) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f3:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: ld [[BHIGH:%f[0-7]]], 0(%r2)
|
|
|
|
; CHECK: ld [[BLOW:%f[0-7]]], 8(%r2)
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr %f0, [[BHIGH]], %f0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2018-07-20 20:12:10 +08:00
|
|
|
%bl = load volatile fp128, fp128 *%bptr
|
2013-05-07 00:17:29 +08:00
|
|
|
%b = fptrunc fp128 %bl to float
|
|
|
|
%res = call float @copysignf(float %a, float %b) readnone
|
|
|
|
ret float %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f64 copies in which the sign comes from an f32.
|
|
|
|
define double @f4(double %a, float %bf) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f4:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK-NOT: %f2
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr %f0, %f2, %f0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
|
|
|
%b = fpext float %bf to double
|
|
|
|
%res = call double @copysign(double %a, double %b) readnone
|
|
|
|
ret double %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f64 copies in which the sign comes from an f64.
|
|
|
|
define double @f5(double %a, double %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f5:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK-NOT: %f2
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr %f0, %f2, %f0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
|
|
|
%res = call double @copysign(double %a, double %b) readnone
|
|
|
|
ret double %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f64 copies in which the sign comes from an f128.
|
|
|
|
define double @f6(double %a, fp128 *%bptr) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f6:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: ld [[BHIGH:%f[0-7]]], 0(%r2)
|
|
|
|
; CHECK: ld [[BLOW:%f[0-7]]], 8(%r2)
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr %f0, [[BHIGH]], %f0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2018-07-20 20:12:10 +08:00
|
|
|
%bl = load volatile fp128, fp128 *%bptr
|
2013-05-07 00:17:29 +08:00
|
|
|
%b = fptrunc fp128 %bl to double
|
|
|
|
%res = call double @copysign(double %a, double %b) readnone
|
|
|
|
ret double %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f128 copies in which the sign comes from an f32. We shouldn't
|
|
|
|
; need any register shuffling here; %a should be tied to %c, with CPSDR
|
|
|
|
; just changing the high register.
|
|
|
|
define void @f7(fp128 *%cptr, fp128 *%aptr, float %bf) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f7:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: ld [[AHIGH:%f[0-7]]], 0(%r3)
|
|
|
|
; CHECK: ld [[ALOW:%f[0-7]]], 8(%r3)
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr [[AHIGH]], %f0, [[AHIGH]]
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: std [[AHIGH]], 0(%r2)
|
|
|
|
; CHECK: std [[ALOW]], 8(%r2)
|
|
|
|
; CHECK: br %r14
|
2018-07-20 20:12:10 +08:00
|
|
|
%a = load volatile fp128, fp128 *%aptr
|
2013-05-07 00:17:29 +08:00
|
|
|
%b = fpext float %bf to fp128
|
|
|
|
%c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
|
|
|
|
store fp128 %c, fp128 *%cptr
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; As above, but the sign comes from an f64.
|
|
|
|
define void @f8(fp128 *%cptr, fp128 *%aptr, double %bd) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f8:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: ld [[AHIGH:%f[0-7]]], 0(%r3)
|
|
|
|
; CHECK: ld [[ALOW:%f[0-7]]], 8(%r3)
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr [[AHIGH]], %f0, [[AHIGH]]
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: std [[AHIGH]], 0(%r2)
|
|
|
|
; CHECK: std [[ALOW]], 8(%r2)
|
|
|
|
; CHECK: br %r14
|
2018-07-20 20:12:10 +08:00
|
|
|
%a = load volatile fp128, fp128 *%aptr
|
2013-05-07 00:17:29 +08:00
|
|
|
%b = fpext double %bd to fp128
|
|
|
|
%c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
|
|
|
|
store fp128 %c, fp128 *%cptr
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; As above, but the sign comes from an f128. Don't require the low part
|
|
|
|
; of %b to be loaded, since it isn't used.
|
|
|
|
define void @f9(fp128 *%cptr, fp128 *%aptr, fp128 *%bptr) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f9:
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: ld [[AHIGH:%f[0-7]]], 0(%r3)
|
|
|
|
; CHECK: ld [[ALOW:%f[0-7]]], 8(%r3)
|
|
|
|
; CHECK: ld [[BHIGH:%f[0-7]]], 0(%r4)
|
2016-05-18 21:24:57 +08:00
|
|
|
; CHECK: cpsdr [[AHIGH]], [[BHIGH]], [[AHIGH]]
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: std [[AHIGH]], 0(%r2)
|
|
|
|
; CHECK: std [[ALOW]], 8(%r2)
|
|
|
|
; CHECK: br %r14
|
2018-07-20 20:12:10 +08:00
|
|
|
%a = load volatile fp128, fp128 *%aptr
|
|
|
|
%b = load volatile fp128, fp128 *%bptr
|
2013-05-07 00:17:29 +08:00
|
|
|
%c = call fp128 @copysignl(fp128 %a, fp128 %b) readnone
|
|
|
|
store fp128 %c, fp128 *%cptr
|
|
|
|
ret void
|
|
|
|
}
|