• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -basicaa -slp-vectorizer -slp-threshold=-999 -dce -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
2
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4target triple = "x86_64-apple-macosx10.8.0"
5
6declare double @sin(double)
7declare double @cos(double)
8declare double @pow(double, double)
9declare double @exp2(double)
10declare i64 @round(i64)
11
12
13; CHECK: sin_libm
14; CHECK: call <2 x double> @llvm.sin.v2f64
15; CHECK: ret void
16define void @sin_libm(double* %a, double* %b, double* %c) {
17entry:
18  %i0 = load double, double* %a, align 8
19  %i1 = load double, double* %b, align 8
20  %mul = fmul double %i0, %i1
21  %call = tail call double @sin(double %mul) nounwind readnone
22  %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
23  %i3 = load double, double* %arrayidx3, align 8
24  %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
25  %i4 = load double, double* %arrayidx4, align 8
26  %mul5 = fmul double %i3, %i4
27  %call5 = tail call double @sin(double %mul5) nounwind readnone
28  store double %call, double* %c, align 8
29  %arrayidx5 = getelementptr inbounds double, double* %c, i64 1
30  store double %call5, double* %arrayidx5, align 8
31  ret void
32}
33
34; CHECK: cos_libm
35; CHECK: call <2 x double> @llvm.cos.v2f64
36; CHECK: ret void
37define void @cos_libm(double* %a, double* %b, double* %c) {
38entry:
39  %i0 = load double, double* %a, align 8
40  %i1 = load double, double* %b, align 8
41  %mul = fmul double %i0, %i1
42  %call = tail call double @cos(double %mul) nounwind readnone
43  %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
44  %i3 = load double, double* %arrayidx3, align 8
45  %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
46  %i4 = load double, double* %arrayidx4, align 8
47  %mul5 = fmul double %i3, %i4
48  %call5 = tail call double @cos(double %mul5) nounwind readnone
49  store double %call, double* %c, align 8
50  %arrayidx5 = getelementptr inbounds double, double* %c, i64 1
51  store double %call5, double* %arrayidx5, align 8
52  ret void
53}
54
55; CHECK: pow_libm
56; CHECK: call <2 x double> @llvm.pow.v2f64
57; CHECK: ret void
58define void @pow_libm(double* %a, double* %b, double* %c) {
59entry:
60  %i0 = load double, double* %a, align 8
61  %i1 = load double, double* %b, align 8
62  %mul = fmul double %i0, %i1
63  %call = tail call double @pow(double %mul,double %mul) nounwind readnone
64  %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
65  %i3 = load double, double* %arrayidx3, align 8
66  %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
67  %i4 = load double, double* %arrayidx4, align 8
68  %mul5 = fmul double %i3, %i4
69  %call5 = tail call double @pow(double %mul5,double %mul5) nounwind readnone
70  store double %call, double* %c, align 8
71  %arrayidx5 = getelementptr inbounds double, double* %c, i64 1
72  store double %call5, double* %arrayidx5, align 8
73  ret void
74}
75
76
77; CHECK: exp2_libm
78; CHECK: call <2 x double> @llvm.exp2.v2f64
79; CHECK: ret void
80define void @exp2_libm(double* %a, double* %b, double* %c) {
81entry:
82  %i0 = load double, double* %a, align 8
83  %i1 = load double, double* %b, align 8
84  %mul = fmul double %i0, %i1
85  %call = tail call double @exp2(double %mul) nounwind readnone
86  %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
87  %i3 = load double, double* %arrayidx3, align 8
88  %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
89  %i4 = load double, double* %arrayidx4, align 8
90  %mul5 = fmul double %i3, %i4
91  %call5 = tail call double @exp2(double %mul5) nounwind readnone
92  store double %call, double* %c, align 8
93  %arrayidx5 = getelementptr inbounds double, double* %c, i64 1
94  store double %call5, double* %arrayidx5, align 8
95  ret void
96}
97
98
99; Negative test case
100; CHECK: round_custom
101; CHECK-NOT: load <4 x i64>
102; CHECK: ret void
103define void @round_custom(i64* %a, i64* %b, i64* %c) {
104entry:
105  %i0 = load i64, i64* %a, align 8
106  %i1 = load i64, i64* %b, align 8
107  %mul = mul i64 %i0, %i1
108  %call = tail call i64 @round(i64 %mul) nounwind readnone
109  %arrayidx3 = getelementptr inbounds i64, i64* %a, i64 1
110  %i3 = load i64, i64* %arrayidx3, align 8
111  %arrayidx4 = getelementptr inbounds i64, i64* %b, i64 1
112  %i4 = load i64, i64* %arrayidx4, align 8
113  %mul5 = mul i64 %i3, %i4
114  %call5 = tail call i64 @round(i64 %mul5) nounwind readnone
115  store i64 %call, i64* %c, align 8
116  %arrayidx5 = getelementptr inbounds i64, i64* %c, i64 1
117  store i64 %call5, i64* %arrayidx5, align 8
118  ret void
119}
120
121
122; CHECK: declare <2 x double> @llvm.sin.v2f64(<2 x double>) [[ATTR0:#[0-9]+]]
123; CHECK: declare <2 x double> @llvm.cos.v2f64(<2 x double>) [[ATTR0]]
124; CHECK: declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>) [[ATTR0]]
125; CHECK: declare <2 x double> @llvm.exp2.v2f64(<2 x double>) [[ATTR0]]
126
127; CHECK: attributes [[ATTR0]] = { nounwind readnone }
128
129