]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/InstCombine/cos-intrinsic.ll
Vendor import of llvm trunk r291274:
[FreeBSD/FreeBSD.git] / test / Transforms / InstCombine / cos-intrinsic.ll
1 ; RUN: opt < %s -instcombine -S | FileCheck %s
2 ; This test makes sure that the undef is propagated for the cos instrinsic
3
4 declare double    @llvm.cos.f64(double %Val)
5 declare float     @llvm.cos.f32(float %Val)
6 declare <2 x float> @llvm.cos.v2f32(<2 x float> %Val)
7
8 declare float @llvm.fabs.f32(float %Val)
9 declare <2 x float> @llvm.fabs.v2f32(<2 x float> %Val)
10
11 ; Function Attrs: nounwind readnone
12 define double @test1() {
13 ; CHECK-LABEL: define double @test1(
14 ; CHECK-NEXT: ret double 0.000000e+00
15   %1 = call double @llvm.cos.f64(double undef)
16   ret double %1
17 }
18
19
20 ; Function Attrs: nounwind readnone
21 define float @test2(float %d) {
22 ; CHECK-LABEL: define float @test2(
23 ; CHECK-NEXT: %cosval = call float @llvm.cos.f32(float %d)
24    %cosval   = call float @llvm.cos.f32(float %d)
25    %cosval2  = call float @llvm.cos.f32(float undef)
26    %fsum   = fadd float %cosval2, %cosval
27    ret float %fsum
28 ; CHECK-NEXT: %fsum
29 ; CHECK: ret float %fsum
30 }
31
32 ; CHECK-LABEL: @cos_fneg_f32(
33 ; CHECK: %cos = call float @llvm.cos.f32(float %x)
34 ; CHECK-NEXT: ret float %cos
35 define float @cos_fneg_f32(float %x) {
36   %x.fneg = fsub float -0.0, %x
37   %cos = call float @llvm.cos.f32(float %x.fneg)
38   ret float %cos
39 }
40
41 ; FIXME: m_FNeg() doesn't handle vectors
42 ; CHECK-LABEL: @cos_fneg_v2f32(
43 ; CHECK: %x.fneg = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %x
44 ; CHECK-NEXT: %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fneg)
45 ; CHECK-NEXT: ret <2 x float> %cos
46 define <2 x float> @cos_fneg_v2f32(<2 x float> %x) {
47   %x.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x
48   %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fneg)
49   ret <2 x float> %cos
50 }
51
52 ; CHECK-LABEL: @cos_fabs_f32(
53 ; CHECK-NEXT: %cos = call float @llvm.cos.f32(float %x)
54 ; CHECK-NEXT: ret float %cos
55 define float @cos_fabs_f32(float %x) {
56   %x.fabs = call float @llvm.fabs.f32(float %x)
57   %cos = call float @llvm.cos.f32(float %x.fabs)
58   ret float %cos
59 }
60
61 ; CHECK-LABEL: @cos_fabs_fneg_f32(
62 ; CHECK: %cos = call float @llvm.cos.f32(float %x)
63 ; CHECK-NEXT: ret float %cos
64 define float @cos_fabs_fneg_f32(float %x) {
65   %x.fabs = call float @llvm.fabs.f32(float %x)
66   %x.fabs.fneg = fsub float -0.0, %x.fabs
67   %cos = call float @llvm.cos.f32(float %x.fabs.fneg)
68   ret float %cos
69 }
70
71 ; CHECK-LABEL: @cos_fabs_fneg_v2f32(
72 ; CHECK: %x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)
73 ; CHECK-NEXT: %x.fabs.fneg = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %x.fabs
74 ; CHECK-NEXT: %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fabs.fneg)
75 ; CHECK-NEXT: ret <2 x float> %cos
76 define <2 x float> @cos_fabs_fneg_v2f32(<2 x float> %x) {
77   %x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)
78   %x.fabs.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x.fabs
79   %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fabs.fneg)
80   ret <2 x float> %cos
81 }