File: cos-intrinsic.ll

package info (click to toggle)
llvm-toolchain-5.0 1:5.0.1-2~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 553,688 kB
  • sloc: cpp: 2,878,786; ansic: 584,110; asm: 246,252; python: 124,751; objc: 106,925; sh: 21,542; lisp: 8,628; pascal: 5,885; ml: 5,544; perl: 5,312; makefile: 2,208; cs: 2,022; xml: 686; php: 212; csh: 117
file content (81 lines) | stat: -rw-r--r-- 2,852 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
; RUN: opt < %s -instcombine -S | FileCheck %s
; This test makes sure that the undef is propagated for the cos instrinsic

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() {
; CHECK-LABEL: define double @test1(
; CHECK-NEXT: ret double 0.000000e+00
  %1 = call double @llvm.cos.f64(double undef)
  ret double %1
}


; Function Attrs: nounwind readnone
define float @test2(float %d) {
; CHECK-LABEL: define float @test2(
; CHECK-NEXT: %cosval = call float @llvm.cos.f32(float %d)
   %cosval   = call float @llvm.cos.f32(float %d)
   %cosval2  = call float @llvm.cos.f32(float undef)
   %fsum   = fadd float %cosval2, %cosval
   ret float %fsum
; 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
}