Skip to content

Commit 02f912a

Browse files
author
v01dxyz
committed
[X86] test pre-commit: Legalise FNEG/FCOPYSIGN (f16) with Expand
1 parent 2847020 commit 02f912a

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

llvm/test/CodeGen/X86/fp16-libcalls.ll

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,104 @@ define void @test_half_fabs(half %a0, ptr %p0) nounwind {
175175
ret void
176176
}
177177

178+
define void @test_half_fneg(half %a0, ptr %p0) nounwind {
179+
; F16C-LABEL: test_half_fneg:
180+
; F16C: # %bb.0:
181+
; F16C-NEXT: vpextrw $0, %xmm0, %eax
182+
; F16C-NEXT: vmovd %eax, %xmm0
183+
; F16C-NEXT: vcvtph2ps %xmm0, %xmm0
184+
; F16C-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
185+
; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
186+
; F16C-NEXT: vmovd %xmm0, %eax
187+
; F16C-NEXT: movw %ax, (%rdi)
188+
; F16C-NEXT: retq
189+
;
190+
; FP16-LABEL: test_half_fneg:
191+
; FP16: # %bb.0:
192+
; FP16-NEXT: vpbroadcastw {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
193+
; FP16-NEXT: vpxor %xmm1, %xmm0, %xmm0
194+
; FP16-NEXT: vmovsh %xmm0, (%rdi)
195+
; FP16-NEXT: retq
196+
;
197+
; X64-LABEL: test_half_fneg:
198+
; X64: # %bb.0:
199+
; X64-NEXT: pushq %rbx
200+
; X64-NEXT: movq %rdi, %rbx
201+
; X64-NEXT: callq __extendhfsf2@PLT
202+
; X64-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
203+
; X64-NEXT: callq __truncsfhf2@PLT
204+
; X64-NEXT: pextrw $0, %xmm0, %eax
205+
; X64-NEXT: movw %ax, (%rbx)
206+
; X64-NEXT: popq %rbx
207+
; X64-NEXT: retq
208+
;
209+
; X86-LABEL: test_half_fneg:
210+
; X86: # %bb.0:
211+
; X86-NEXT: pushl %esi
212+
; X86-NEXT: subl $8, %esp
213+
; X86-NEXT: pinsrw $0, {{[0-9]+}}(%esp), %xmm0
214+
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
215+
; X86-NEXT: pextrw $0, %xmm0, %eax
216+
; X86-NEXT: movw %ax, (%esp)
217+
; X86-NEXT: calll __extendhfsf2
218+
; X86-NEXT: fstps {{[0-9]+}}(%esp)
219+
; X86-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
220+
; X86-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
221+
; X86-NEXT: movd %xmm0, (%esp)
222+
; X86-NEXT: calll __truncsfhf2
223+
; X86-NEXT: pextrw $0, %xmm0, %eax
224+
; X86-NEXT: movw %ax, (%esi)
225+
; X86-NEXT: addl $8, %esp
226+
; X86-NEXT: popl %esi
227+
; X86-NEXT: retl
228+
%res = fneg half %a0
229+
store half %res, ptr %p0, align 2
230+
ret void
231+
}
232+
233+
define void @test_half_fcopysign(half %a0, half %a1, ptr %p0) nounwind {
234+
; F16C-LABEL: test_half_fcopysign:
235+
; F16C: # %bb.0:
236+
; F16C-NEXT: vpextrw $0, %xmm1, %eax
237+
; F16C-NEXT: andl $32768, %eax # imm = 0x8000
238+
; F16C-NEXT: vpextrw $0, %xmm0, %ecx
239+
; F16C-NEXT: andl $32767, %ecx # imm = 0x7FFF
240+
; F16C-NEXT: orl %eax, %ecx
241+
; F16C-NEXT: movw %cx, (%rdi)
242+
; F16C-NEXT: retq
243+
;
244+
; FP16-LABEL: test_half_fcopysign:
245+
; FP16: # %bb.0:
246+
; FP16-NEXT: vpbroadcastw {{.*#+}} xmm2 = [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN]
247+
; FP16-NEXT: vpternlogd $202, %xmm1, %xmm0, %xmm2
248+
; FP16-NEXT: vmovsh %xmm2, (%rdi)
249+
; FP16-NEXT: retq
250+
;
251+
; X64-LABEL: test_half_fcopysign:
252+
; X64: # %bb.0:
253+
; X64-NEXT: pextrw $0, %xmm1, %eax
254+
; X64-NEXT: andl $32768, %eax # imm = 0x8000
255+
; X64-NEXT: pextrw $0, %xmm0, %ecx
256+
; X64-NEXT: andl $32767, %ecx # imm = 0x7FFF
257+
; X64-NEXT: orl %eax, %ecx
258+
; X64-NEXT: movw %cx, (%rdi)
259+
; X64-NEXT: retq
260+
;
261+
; X86-LABEL: test_half_fcopysign:
262+
; X86: # %bb.0:
263+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
264+
; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
265+
; X86-NEXT: andl $32768, %ecx # imm = 0x8000
266+
; X86-NEXT: movzwl {{[0-9]+}}(%esp), %edx
267+
; X86-NEXT: andl $32767, %edx # imm = 0x7FFF
268+
; X86-NEXT: orl %ecx, %edx
269+
; X86-NEXT: movw %dx, (%eax)
270+
; X86-NEXT: retl
271+
%res = call half @llvm.copysign.half(half %a0, half %a1)
272+
store half %res, ptr %p0, align 2
273+
ret void
274+
}
275+
178276
define void @test_half_pow(half %a0, half %a1, ptr %p0) nounwind {
179277
; F16C-LABEL: test_half_pow:
180278
; F16C: # %bb.0:

0 commit comments

Comments
 (0)