1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+f16c | FileCheck %s --check-prefix=F16C
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+f16c -O0 | FileCheck %s --check-prefix=F16C-O0
7 define <1 x half> @ir_fadd_v1f16(<1 x half> %arg0, <1 x half> %arg1) nounwind {
8 ; X86-LABEL: ir_fadd_v1f16:
10 ; X86-NEXT: subl $28, %esp
11 ; X86-NEXT: movups %xmm1, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
12 ; X86-NEXT: pextrw $0, %xmm0, %eax
13 ; X86-NEXT: movw %ax, (%esp)
14 ; X86-NEXT: calll __extendhfsf2
15 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
16 ; X86-NEXT: pextrw $0, %xmm0, %eax
17 ; X86-NEXT: movw %ax, (%esp)
18 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
19 ; X86-NEXT: calll __extendhfsf2
20 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
21 ; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
22 ; X86-NEXT: addss {{[0-9]+}}(%esp), %xmm0
23 ; X86-NEXT: movss %xmm0, (%esp)
24 ; X86-NEXT: calll __truncsfhf2
25 ; X86-NEXT: addl $28, %esp
28 ; X64-LABEL: ir_fadd_v1f16:
30 ; X64-NEXT: subq $40, %rsp
31 ; X64-NEXT: movaps %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
32 ; X64-NEXT: movaps %xmm1, %xmm0
33 ; X64-NEXT: callq __extendhfsf2@PLT
34 ; X64-NEXT: movss %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 4-byte Spill
35 ; X64-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
36 ; X64-NEXT: callq __extendhfsf2@PLT
37 ; X64-NEXT: addss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 4-byte Folded Reload
38 ; X64-NEXT: callq __truncsfhf2@PLT
39 ; X64-NEXT: addq $40, %rsp
42 ; F16C-LABEL: ir_fadd_v1f16:
44 ; F16C-NEXT: vcvtph2ps %xmm1, %xmm1
45 ; F16C-NEXT: vcvtph2ps %xmm0, %xmm0
46 ; F16C-NEXT: vaddss %xmm1, %xmm0, %xmm0
47 ; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
48 ; F16C-NEXT: vmovd %xmm0, %eax
49 ; F16C-NEXT: vpinsrw $0, %eax, %xmm0, %xmm0
52 ; F16C-O0-LABEL: ir_fadd_v1f16:
54 ; F16C-O0-NEXT: vpextrw $0, %xmm1, %eax
55 ; F16C-O0-NEXT: movw %ax, %cx
56 ; F16C-O0-NEXT: # implicit-def: $eax
57 ; F16C-O0-NEXT: movw %cx, %ax
58 ; F16C-O0-NEXT: vmovd %eax, %xmm1
59 ; F16C-O0-NEXT: vcvtph2ps %xmm1, %xmm1
60 ; F16C-O0-NEXT: vpextrw $0, %xmm0, %eax
61 ; F16C-O0-NEXT: movw %ax, %cx
62 ; F16C-O0-NEXT: # implicit-def: $eax
63 ; F16C-O0-NEXT: movw %cx, %ax
64 ; F16C-O0-NEXT: vmovd %eax, %xmm0
65 ; F16C-O0-NEXT: vcvtph2ps %xmm0, %xmm0
66 ; F16C-O0-NEXT: vaddss %xmm1, %xmm0, %xmm0
67 ; F16C-O0-NEXT: vcvtps2ph $4, %xmm0, %xmm0
68 ; F16C-O0-NEXT: vmovd %xmm0, %eax
69 ; F16C-O0-NEXT: movw %ax, %cx
70 ; F16C-O0-NEXT: # implicit-def: $eax
71 ; F16C-O0-NEXT: movw %cx, %ax
72 ; F16C-O0-NEXT: # implicit-def: $xmm0
73 ; F16C-O0-NEXT: vpinsrw $0, %eax, %xmm0, %xmm0
75 %retval = fadd <1 x half> %arg0, %arg1
76 ret <1 x half> %retval
79 define <2 x half> @ir_fadd_v2f16(<2 x half> %arg0, <2 x half> %arg1) nounwind {
80 ; X86-LABEL: ir_fadd_v2f16:
82 ; X86-NEXT: subl $84, %esp
83 ; X86-NEXT: movdqu %xmm0, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
84 ; X86-NEXT: psrld $16, %xmm0
85 ; X86-NEXT: movdqu %xmm0, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
86 ; X86-NEXT: movdqa %xmm1, %xmm0
87 ; X86-NEXT: psrld $16, %xmm0
88 ; X86-NEXT: movdqu %xmm0, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
89 ; X86-NEXT: pextrw $0, %xmm1, %eax
90 ; X86-NEXT: movw %ax, (%esp)
91 ; X86-NEXT: calll __extendhfsf2
92 ; X86-NEXT: fstpt {{[-0-9]+}}(%e{{[sb]}}p) # 10-byte Folded Spill
93 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
94 ; X86-NEXT: pextrw $0, %xmm0, %eax
95 ; X86-NEXT: movw %ax, (%esp)
96 ; X86-NEXT: calll __extendhfsf2
97 ; X86-NEXT: fstpt {{[-0-9]+}}(%e{{[sb]}}p) # 10-byte Folded Spill
98 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
99 ; X86-NEXT: pextrw $0, %xmm0, %eax
100 ; X86-NEXT: movw %ax, (%esp)
101 ; X86-NEXT: calll __extendhfsf2
102 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
103 ; X86-NEXT: pextrw $0, %xmm0, %eax
104 ; X86-NEXT: movw %ax, (%esp)
105 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
106 ; X86-NEXT: fldt {{[-0-9]+}}(%e{{[sb]}}p) # 10-byte Folded Reload
107 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
108 ; X86-NEXT: calll __extendhfsf2
109 ; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
110 ; X86-NEXT: addss {{[0-9]+}}(%esp), %xmm0
111 ; X86-NEXT: movss %xmm0, (%esp)
112 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
113 ; X86-NEXT: fldt {{[-0-9]+}}(%e{{[sb]}}p) # 10-byte Folded Reload
114 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
115 ; X86-NEXT: calll __truncsfhf2
116 ; X86-NEXT: movups %xmm0, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
117 ; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
118 ; X86-NEXT: addss {{[0-9]+}}(%esp), %xmm0
119 ; X86-NEXT: movss %xmm0, (%esp)
120 ; X86-NEXT: calll __truncsfhf2
121 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm1 # 16-byte Reload
122 ; X86-NEXT: punpcklwd {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
123 ; X86-NEXT: addl $84, %esp
126 ; X64-LABEL: ir_fadd_v2f16:
128 ; X64-NEXT: subq $72, %rsp
129 ; X64-NEXT: movdqa %xmm1, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
130 ; X64-NEXT: movdqa %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
131 ; X64-NEXT: psrld $16, %xmm0
132 ; X64-NEXT: movdqa %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
133 ; X64-NEXT: movdqa %xmm1, %xmm0
134 ; X64-NEXT: psrld $16, %xmm0
135 ; X64-NEXT: callq __extendhfsf2@PLT
136 ; X64-NEXT: movd %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 4-byte Folded Spill
137 ; X64-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
138 ; X64-NEXT: callq __extendhfsf2@PLT
139 ; X64-NEXT: addss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 4-byte Folded Reload
140 ; X64-NEXT: callq __truncsfhf2@PLT
141 ; X64-NEXT: movaps %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
142 ; X64-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
143 ; X64-NEXT: callq __extendhfsf2@PLT
144 ; X64-NEXT: movss %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 4-byte Spill
145 ; X64-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
146 ; X64-NEXT: callq __extendhfsf2@PLT
147 ; X64-NEXT: addss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 4-byte Folded Reload
148 ; X64-NEXT: callq __truncsfhf2@PLT
149 ; X64-NEXT: punpcklwd {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Folded Reload
150 ; X64-NEXT: # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1],xmm0[2],mem[2],xmm0[3],mem[3]
151 ; X64-NEXT: addq $72, %rsp
154 ; F16C-LABEL: ir_fadd_v2f16:
156 ; F16C-NEXT: vcvtph2ps %xmm1, %ymm1
157 ; F16C-NEXT: vcvtph2ps %xmm0, %ymm0
158 ; F16C-NEXT: vaddps %ymm1, %ymm0, %ymm0
159 ; F16C-NEXT: vcvtps2ph $4, %ymm0, %xmm0
160 ; F16C-NEXT: vzeroupper
163 ; F16C-O0-LABEL: ir_fadd_v2f16:
165 ; F16C-O0-NEXT: vcvtph2ps %xmm1, %ymm1
166 ; F16C-O0-NEXT: vcvtph2ps %xmm0, %ymm0
167 ; F16C-O0-NEXT: vaddps %ymm1, %ymm0, %ymm0
168 ; F16C-O0-NEXT: vcvtps2ph $4, %ymm0, %xmm0
169 ; F16C-O0-NEXT: vzeroupper
171 %retval = fadd <2 x half> %arg0, %arg1
172 ret <2 x half> %retval