summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/cos-intrinsic.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/InstCombine/cos-intrinsic.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/cos-intrinsic.ll55
1 files changed, 55 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/cos-intrinsic.ll b/llvm/test/Transforms/InstCombine/cos-intrinsic.ll
index b4d07cf8047..24b605e9c8c 100644
--- a/llvm/test/Transforms/InstCombine/cos-intrinsic.ll
+++ b/llvm/test/Transforms/InstCombine/cos-intrinsic.ll
@@ -3,6 +3,10 @@
declare double @llvm.cos.f64(double %Val)
declare float @llvm.cos.f32(float %Val)
+declare <2 x float> @llvm.cos.v2f32(<2 x float> %Val)
+
+declare float @llvm.fabs.f32(float %Val)
+declare <2 x float> @llvm.fabs.v2f32(<2 x float> %Val)
; Function Attrs: nounwind readnone
define double @test1() {
@@ -24,3 +28,54 @@ define float @test2(float %d) {
; CHECK-NEXT: %fsum
; CHECK: ret float %fsum
}
+
+; CHECK-LABEL: @cos_fneg_f32(
+; CHECK: %cos = call float @llvm.cos.f32(float %x)
+; CHECK-NEXT: ret float %cos
+define float @cos_fneg_f32(float %x) {
+ %x.fneg = fsub float -0.0, %x
+ %cos = call float @llvm.cos.f32(float %x.fneg)
+ ret float %cos
+}
+
+; FIXME: m_FNeg() doesn't handle vectors
+; CHECK-LABEL: @cos_fneg_v2f32(
+; CHECK: %x.fneg = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %x
+; CHECK-NEXT: %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fneg)
+; CHECK-NEXT: ret <2 x float> %cos
+define <2 x float> @cos_fneg_v2f32(<2 x float> %x) {
+ %x.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x
+ %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fneg)
+ ret <2 x float> %cos
+}
+
+; CHECK-LABEL: @cos_fabs_f32(
+; CHECK-NEXT: %cos = call float @llvm.cos.f32(float %x)
+; CHECK-NEXT: ret float %cos
+define float @cos_fabs_f32(float %x) {
+ %x.fabs = call float @llvm.fabs.f32(float %x)
+ %cos = call float @llvm.cos.f32(float %x.fabs)
+ ret float %cos
+}
+
+; CHECK-LABEL: @cos_fabs_fneg_f32(
+; CHECK: %cos = call float @llvm.cos.f32(float %x)
+; CHECK-NEXT: ret float %cos
+define float @cos_fabs_fneg_f32(float %x) {
+ %x.fabs = call float @llvm.fabs.f32(float %x)
+ %x.fabs.fneg = fsub float -0.0, %x.fabs
+ %cos = call float @llvm.cos.f32(float %x.fabs.fneg)
+ ret float %cos
+}
+
+; CHECK-LABEL: @cos_fabs_fneg_v2f32(
+; CHECK: %x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)
+; CHECK-NEXT: %x.fabs.fneg = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %x.fabs
+; CHECK-NEXT: %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fabs.fneg)
+; CHECK-NEXT: ret <2 x float> %cos
+define <2 x float> @cos_fabs_fneg_v2f32(<2 x float> %x) {
+ %x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)
+ %x.fabs.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x.fabs
+ %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fabs.fneg)
+ ret <2 x float> %cos
+}
OpenPOWER on IntegriCloud