blob: 468c11f95e9a62703534a83bd69ec93a93edbe79 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt -S -mtriple=amdgpu-amd-amdhsa -passes=amdgpu-simplifylib %s | FileCheck %s
; Constant folding of fast-math library calls (evaluateCall).
declare float @_Z3sinf(float)
declare <2 x float> @_Z3cosDv2_f(<2 x float>)
declare <2 x float> @_Z3powDv2_fS_(<2 x float>, <2 x float>)
declare <2 x float> @_Z4fminDv2_ff(<2 x float>, float)
declare <2 x float> @_Z4fminDv2_fS_(float, <2 x float>)
declare <2 x float> @_Z6sincosDv2_fPU3AS5S_(<2 x float>, ptr addrspace(5))
define <2 x float> @fold_cos_v2f32() {
; CHECK-LABEL: define <2 x float> @fold_cos_v2f32() {
; CHECK-NEXT: ret <2 x float> <float f0xBF7D7026, float f0xBF275530>
;
%r = call fast <2 x float> @_Z3cosDv2_f(<2 x float> <float 3.0, float 4.0>)
ret <2 x float> %r
}
define <2 x float> @fold_cos_v2f32_zeroinit() {
; CHECK-LABEL: define <2 x float> @fold_cos_v2f32_zeroinit() {
; CHECK-NEXT: ret <2 x float> splat (float 1.000000e+00)
;
%r = call fast <2 x float> @_Z3cosDv2_f(<2 x float> zeroinitializer)
ret <2 x float> %r
}
; A poison lane must not turn the defined lanes into an evaluation at 0.0;
; cos(3.0) is about -0.99, not cos(0.0) == 1.0.
define <2 x float> @no_fold_cos_v2f32_poison_lane() {
; CHECK-LABEL: define <2 x float> @no_fold_cos_v2f32_poison_lane() {
; CHECK-NEXT: [[R:%.*]] = call fast <2 x float> @_Z3cosDv2_f(<2 x float> <float 3.000000e+00, float poison>)
; CHECK-NEXT: ret <2 x float> [[R]]
;
%r = call fast <2 x float> @_Z3cosDv2_f(<2 x float> <float 3.0, float poison>)
ret <2 x float> %r
}
; Likewise for the second operand: a poison exponent lane must not be
; evaluated as pow(x, 0.0) == 1.0. (The defined lanes are still folded, by the
; pow(x, 2) => x*x expansion.)
define <2 x float> @pow_v2f32_poison_exp_lane() {
; CHECK-LABEL: define <2 x float> @pow_v2f32_poison_exp_lane() {
; CHECK-NEXT: ret <2 x float> <float 9.000000e+00, float 1.600000e+01>
;
%r = call fast <2 x float> @_Z3powDv2_fS_(<2 x float> <float 3.0, float 4.0>, <2 x float> <float 2.0, float poison>)
ret <2 x float> %r
}
define float @no_fold_sin_f32_poison() {
; CHECK-LABEL: define float @no_fold_sin_f32_poison() {
; CHECK-NEXT: [[R:%.*]] = call fast float @_Z3sinf(float poison)
; CHECK-NEXT: ret float [[R]]
;
%r = call fast float @_Z3sinf(float poison)
ret float %r
}
; fmin/fmax/ldexp signatures accept an implicitly splatted scalar operand, and
; sincos takes a pointer; the vector evaluation loop must not index into them.
define <2 x float> @fmin_v2f32_scalar_second_arg() {
; CHECK-LABEL: define <2 x float> @fmin_v2f32_scalar_second_arg() {
; CHECK-NEXT: [[R:%.*]] = call fast <2 x float> @llvm.minnum.v2f32(<2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float> splat (float 1.500000e+00))
; CHECK-NEXT: ret <2 x float> [[R]]
;
%r = call fast <2 x float> @_Z4fminDv2_ff(<2 x float> <float 1.0, float 2.0>, float 1.5)
ret <2 x float> %r
}
define <2 x float> @fmin_v2f32_scalar_first_arg() {
; CHECK-LABEL: define <2 x float> @fmin_v2f32_scalar_first_arg() {
; CHECK-NEXT: [[R:%.*]] = call fast <2 x float> @llvm.minnum.v2f32(<2 x float> splat (float 1.500000e+00), <2 x float> <float 1.000000e+00, float 2.000000e+00>)
; CHECK-NEXT: ret <2 x float> [[R]]
;
%r = call fast <2 x float> @_Z4fminDv2_fS_(float 1.5, <2 x float> <float 1.0, float 2.0>)
ret <2 x float> %r
}
define <2 x float> @sincos_v2f32(ptr addrspace(5) %p) {
; CHECK-LABEL: define <2 x float> @sincos_v2f32(
; CHECK-SAME: ptr addrspace(5) [[P:%.*]]) {
; CHECK-NEXT: store <2 x float> <float f0x3F0A5140, float f0xBED51133>, ptr addrspace(5) [[P]], align 8
; CHECK-NEXT: ret <2 x float> <float f0x3F576AA4, float f0x3F68C7B7>
;
%r = call fast <2 x float> @_Z6sincosDv2_fPU3AS5S_(<2 x float> <float 1.0, float 2.0>, ptr addrspace(5) %p)
ret <2 x float> %r
}