Mercurial > hg > CbC > CbC_llvm
comparison test/CodeGen/X86/sse-fcopysign.ll @ 95:afa8332a0e37 LLVM3.8
LLVM 3.8
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Oct 2015 17:48:58 +0900 |
parents | 95c75e76d11b |
children | 1172e4bd9c6f |
comparison
equal
deleted
inserted
replaced
84:f3e34b893a5f | 95:afa8332a0e37 |
---|---|
1 ; RUN: llc < %s -march=x86 -mattr=+sse2 | not grep test | 1 ; RUN: llc < %s -mtriple=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefix=ALL --check-prefix=X32 |
2 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+sse2 | FileCheck %s --check-prefix=ALL --check-prefix=X64 | |
3 | |
4 ; | |
5 ; Library Functions | |
6 ; | |
2 | 7 |
3 define float @tst1(float %a, float %b) { | 8 define float @tst1(float %a, float %b) { |
4 %tmp = tail call float @copysignf( float %b, float %a ) | 9 ; X32-LABEL: @tst1 |
5 ret float %tmp | 10 ; X32: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero |
11 ; X32-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero | |
12 ; X32-NEXT: movss %xmm1, 4(%esp) | |
13 ; X32-NEXT: movss %xmm0, (%esp) | |
14 ; X32-NEXT: calll copysignf | |
15 ; X32-NEXT: addl $8, %esp | |
16 ; X32-NEXT: retl | |
17 ; | |
18 ; X64-LABEL: @tst1 | |
19 ; X64: movaps %xmm0, %xmm2 | |
20 ; X64-NEXT: movaps %xmm1, %xmm0 | |
21 ; X64-NEXT: movaps %xmm2, %xmm1 | |
22 ; X64-NEXT: jmp copysignf | |
23 %tmp = tail call float @copysignf( float %b, float %a ) | |
24 ret float %tmp | |
6 } | 25 } |
7 | 26 |
8 define double @tst2(double %a, float %b, float %c) { | 27 define double @tst2(double %a, float %b, float %c) { |
9 %tmp1 = fadd float %b, %c | 28 ; X32-LABEL: @tst2 |
10 %tmp2 = fpext float %tmp1 to double | 29 ; X32: movsd {{.*#+}} xmm0 = mem[0],zero |
11 %tmp = tail call double @copysign( double %a, double %tmp2 ) | 30 ; X32-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero |
12 ret double %tmp | 31 ; X32-NEXT: addss 32(%esp), %xmm1 |
32 ; X32-NEXT: cvtss2sd %xmm1, %xmm1 | |
33 ; X32-NEXT: movsd %xmm0, (%esp) | |
34 ; X32-NEXT: movsd %xmm1, 8(%esp) | |
35 ; X32-NEXT: calll copysign | |
36 ; X32-NEXT: addl $16, %esp | |
37 ; X32-NEXT: retl | |
38 ; | |
39 ; X64-LABEL: @tst2 | |
40 ; X64: addss %xmm2, %xmm1 | |
41 ; X64-NEXT: cvtss2sd %xmm1, %xmm1 | |
42 ; X64-NEXT: jmp copysign | |
43 %tmp1 = fadd float %b, %c | |
44 %tmp2 = fpext float %tmp1 to double | |
45 %tmp = tail call double @copysign( double %a, double %tmp2 ) | |
46 ret double %tmp | |
13 } | 47 } |
14 | 48 |
15 declare float @copysignf(float, float) | 49 declare float @copysignf(float, float) |
16 declare double @copysign(double, double) | 50 declare double @copysign(double, double) |
51 | |
52 ; | |
53 ; LLVM Intrinsic | |
54 ; | |
55 | |
56 define float @int1(float %a, float %b) { | |
57 ; X32-LABEL: @int1 | |
58 ; X32: movss 8(%esp), %xmm0 {{.*#+}} xmm0 = mem[0],zero,zero,zero | |
59 ; X32-NEXT: andps .LCPI2_0, %xmm0 | |
60 ; X32-NEXT: movss 12(%esp), %xmm1 {{.*#+}} xmm1 = mem[0],zero,zero,zero | |
61 ; X32-NEXT: andps .LCPI2_1, %xmm1 | |
62 ; X32-NEXT: orps %xmm0, %xmm1 | |
63 ; X32-NEXT: movss %xmm1, (%esp) | |
64 ; X32-NEXT: flds (%esp) | |
65 ; X32-NEXT: popl %eax | |
66 ; X32-NEXT: retl | |
67 ; | |
68 ; X64-LABEL: @int1 | |
69 ; X64: andps .LCPI2_0(%rip), %xmm0 | |
70 ; X64-NEXT: andps .LCPI2_1(%rip), %xmm1 | |
71 ; X64-NEXT: orps %xmm1, %xmm0 | |
72 ; X64-NEXT: retq | |
73 %tmp = tail call float @llvm.copysign.f32( float %b, float %a ) | |
74 ret float %tmp | |
75 } | |
76 | |
77 define double @int2(double %a, float %b, float %c) { | |
78 ; X32-LABEL: @int2 | |
79 ; X32: movss 16(%ebp), %xmm0 {{.*#+}} xmm0 = mem[0],zero,zero,zero | |
80 ; X32-NEXT: addss 20(%ebp), %xmm0 | |
81 ; X32-NEXT: movsd 8(%ebp), %xmm1 {{.*#+}} xmm1 = mem[0],zero | |
82 ; X32-NEXT: andpd .LCPI3_0, %xmm1 | |
83 ; X32-NEXT: cvtss2sd %xmm0, %xmm0 | |
84 ; X32-NEXT: andpd .LCPI3_1, %xmm0 | |
85 ; X32-NEXT: orpd %xmm1, %xmm0 | |
86 ; X32-NEXT: movlpd %xmm0, (%esp) | |
87 ; X32-NEXT: fldl (%esp) | |
88 ; X32-NEXT: movl %ebp, %esp | |
89 ; X32-NEXT: popl %ebp | |
90 ; X32-NEXT: retl | |
91 ; | |
92 ; X64-LABEL: @int2 | |
93 ; X64: addss %xmm2, %xmm1 | |
94 ; X64-NEXT: cvtss2sd %xmm1, %xmm1 | |
95 ; X64-NEXT: andpd .LCPI3_0(%rip), %xmm1 | |
96 ; X64-NEXT: andpd .LCPI3_1(%rip), %xmm0 | |
97 ; X64-NEXT: orpd %xmm1, %xmm0 | |
98 ; X64-NEXT: retq | |
99 %tmp1 = fadd float %b, %c | |
100 %tmp2 = fpext float %tmp1 to double | |
101 %tmp = tail call double @llvm.copysign.f64( double %a, double %tmp2 ) | |
102 ret double %tmp | |
103 } | |
104 | |
105 define float @cst1() { | |
106 ; X32-LABEL: @cst1 | |
107 ; X32: fld1 | |
108 ; X32-NEXT: fchs | |
109 ; X32-NEXT: retl | |
110 ; | |
111 ; X64-LABEL: @cst1 | |
112 ; X64: movss .LCPI4_0(%rip), %xmm0 {{.*#+}} xmm0 = mem[0],zero,zero,zero | |
113 ; X64-NEXT: retq | |
114 %tmp = tail call float @llvm.copysign.f32( float 1.0, float -2.0 ) | |
115 ret float %tmp | |
116 } | |
117 | |
118 define double @cst2() { | |
119 ; X32-LABEL: @cst2 | |
120 ; X32: fldz | |
121 ; X32-NEXT: fchs | |
122 ; X32-NEXT: retl | |
123 ; | |
124 ; X64-LABEL: @cst2 | |
125 ; X64: movsd .LCPI5_0(%rip), %xmm0 {{.*#+}} xmm0 = mem[0],zero | |
126 ; X64-NEXT: retq | |
127 %tmp1 = fadd float -1.0, -1.0 | |
128 %tmp2 = fpext float %tmp1 to double | |
129 %tmp = tail call double @llvm.copysign.f64( double 0.0, double %tmp2 ) | |
130 ret double %tmp | |
131 } | |
132 | |
133 declare float @llvm.copysign.f32(float %Mag, float %Sgn) | |
134 declare double @llvm.copysign.f64(double %Mag, double %Sgn) |