Skip to content

Commit 1710821

Browse files
author
v01dxyz
committed
[X86][LegalizeDAG] FPOWI: promote f16 operand
1 parent 2847020 commit 1710821

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
614614
setOperationAction(ISD::FTAN, VT, Action);
615615
setOperationAction(ISD::FSQRT, VT, Action);
616616
setOperationAction(ISD::FPOW, VT, Action);
617+
setOperationAction(ISD::FPOWI, VT, Action);
617618
setOperationAction(ISD::FLOG, VT, Action);
618619
setOperationAction(ISD::FLOG2, VT, Action);
619620
setOperationAction(ISD::FLOG10, VT, Action);

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,77 @@ define void @test_half_pow(half %a0, half %a1, ptr %p0) nounwind {
259259
ret void
260260
}
261261

262+
define void @test_half_powi(half %a0, i32 %a1, ptr %p0) nounwind {
263+
; F16C-LABEL: test_half_powi:
264+
; F16C: # %bb.0:
265+
; F16C-NEXT: pushq %rbx
266+
; F16C-NEXT: movq %rsi, %rbx
267+
; F16C-NEXT: vpextrw $0, %xmm0, %eax
268+
; F16C-NEXT: vmovd %eax, %xmm0
269+
; F16C-NEXT: vcvtph2ps %xmm0, %xmm0
270+
; F16C-NEXT: callq __powisf2@PLT
271+
; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
272+
; F16C-NEXT: vmovd %xmm0, %eax
273+
; F16C-NEXT: movw %ax, (%rbx)
274+
; F16C-NEXT: popq %rbx
275+
; F16C-NEXT: retq
276+
;
277+
; FP16-LABEL: test_half_powi:
278+
; FP16: # %bb.0:
279+
; FP16-NEXT: pushq %rbx
280+
; FP16-NEXT: movq %rsi, %rbx
281+
; FP16-NEXT: vcvtsh2ss %xmm0, %xmm0, %xmm0
282+
; FP16-NEXT: callq __powisf2@PLT
283+
; FP16-NEXT: vcvtss2sh %xmm0, %xmm0, %xmm0
284+
; FP16-NEXT: vmovsh %xmm0, (%rbx)
285+
; FP16-NEXT: popq %rbx
286+
; FP16-NEXT: retq
287+
;
288+
; X64-LABEL: test_half_powi:
289+
; X64: # %bb.0:
290+
; X64-NEXT: pushq %rbp
291+
; X64-NEXT: pushq %rbx
292+
; X64-NEXT: pushq %rax
293+
; X64-NEXT: movq %rsi, %rbx
294+
; X64-NEXT: movl %edi, %ebp
295+
; X64-NEXT: callq __extendhfsf2@PLT
296+
; X64-NEXT: movl %ebp, %edi
297+
; X64-NEXT: callq __powisf2@PLT
298+
; X64-NEXT: callq __truncsfhf2@PLT
299+
; X64-NEXT: pextrw $0, %xmm0, %eax
300+
; X64-NEXT: movw %ax, (%rbx)
301+
; X64-NEXT: addq $8, %rsp
302+
; X64-NEXT: popq %rbx
303+
; X64-NEXT: popq %rbp
304+
; X64-NEXT: retq
305+
;
306+
; X86-LABEL: test_half_powi:
307+
; X86: # %bb.0:
308+
; X86-NEXT: pushl %edi
309+
; X86-NEXT: pushl %esi
310+
; X86-NEXT: subl $20, %esp
311+
; X86-NEXT: pinsrw $0, {{[0-9]+}}(%esp), %xmm0
312+
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
313+
; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
314+
; X86-NEXT: pextrw $0, %xmm0, %eax
315+
; X86-NEXT: movw %ax, (%esp)
316+
; X86-NEXT: calll __extendhfsf2
317+
; X86-NEXT: movl %edi, {{[0-9]+}}(%esp)
318+
; X86-NEXT: fstps (%esp)
319+
; X86-NEXT: calll __powisf2
320+
; X86-NEXT: fstps (%esp)
321+
; X86-NEXT: calll __truncsfhf2
322+
; X86-NEXT: pextrw $0, %xmm0, %eax
323+
; X86-NEXT: movw %ax, (%esi)
324+
; X86-NEXT: addl $20, %esp
325+
; X86-NEXT: popl %esi
326+
; X86-NEXT: popl %edi
327+
; X86-NEXT: retl
328+
%res = call half @llvm.powi.half(half %a0, i32 %a1)
329+
store half %res, ptr %p0, align 2
330+
ret void
331+
}
332+
262333
define void @test_half_sin(half %a0, ptr %p0) nounwind {
263334
; F16C-LABEL: test_half_sin:
264335
; F16C: # %bb.0:

0 commit comments

Comments
 (0)