Skip to content

Commit 4509bc1

Browse files
[X86][GlobalISel] Enable POWI function with libcall mapping (#134369)
1 parent e2fe787 commit 4509bc1

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
9999
.widenScalarToNextPow2(0, /*Min=*/8)
100100
.clampScalar(0, s8, sMaxScalar);
101101

102-
getActionDefinitionsBuilder({G_LROUND, G_LLROUND, G_FCOS, G_FCOSH, G_FACOS,
103-
G_FSIN, G_FSINH, G_FASIN, G_FTAN, G_FTANH,
104-
G_FATAN, G_FATAN2, G_FPOW, G_FEXP, G_FEXP2,
105-
G_FEXP10, G_FLOG, G_FLOG2, G_FLOG10})
102+
getActionDefinitionsBuilder({G_LROUND, G_LLROUND, G_FCOS, G_FCOSH, G_FACOS,
103+
G_FSIN, G_FSINH, G_FASIN, G_FTAN, G_FTANH,
104+
G_FATAN, G_FATAN2, G_FPOW, G_FEXP, G_FEXP2,
105+
G_FEXP10, G_FLOG, G_FLOG2, G_FLOG10, G_FPOWI})
106106
.libcall();
107107

108108
getActionDefinitionsBuilder(G_FSQRT)

llvm/test/CodeGen/X86/powi.ll

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
22
; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel | FileCheck %s --check-prefixes=FAST-X86
33
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 -fast-isel=0 | FileCheck %s --check-prefixes=SDAG-X86
4-
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X86
4+
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86
55
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -fast-isel | FileCheck %s --check-prefixes=FAST-X64
66
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 -fast-isel=0 | FileCheck %s --check-prefixes=SDAG-X64
7-
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X64
7+
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64
88

99
define float @test_powi_f32_i32(float %Val, i32 %x) nounwind {
1010
; FAST-X86-LABEL: test_powi_f32_i32:
@@ -32,10 +32,10 @@ define float @test_powi_f32_i32(float %Val, i32 %x) nounwind {
3232
; GISEL-X86-LABEL: test_powi_f32_i32:
3333
; GISEL-X86: # %bb.0:
3434
; GISEL-X86-NEXT: subl $12, %esp
35-
; GISEL-X86-NEXT: flds {{[0-9]+}}(%esp)
3635
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
37-
; GISEL-X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
38-
; GISEL-X86-NEXT: fstps (%esp)
36+
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
37+
; GISEL-X86-NEXT: movl %eax, (%esp)
38+
; GISEL-X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
3939
; GISEL-X86-NEXT: calll __powisf2
4040
; GISEL-X86-NEXT: addl $12, %esp
4141
; GISEL-X86-NEXT: retl
@@ -53,7 +53,10 @@ define float @test_powi_f32_i32(float %Val, i32 %x) nounwind {
5353
;
5454
; GISEL-X64-LABEL: test_powi_f32_i32:
5555
; GISEL-X64: # %bb.0:
56-
; GISEL-X64-NEXT: jmp __powisf2@PLT # TAILCALL
56+
; GISEL-X64-NEXT: pushq %rax
57+
; GISEL-X64-NEXT: callq __powisf2
58+
; GISEL-X64-NEXT: popq %rax
59+
; GISEL-X64-NEXT: retq
5760
%res = call float @llvm.powi.f32.i32(float %Val, i32 %x)
5861
ret float %res
5962
}
@@ -83,13 +86,20 @@ define double @test_powi_f64_i32(double %Val, i32 %x) nounwind {
8386
;
8487
; GISEL-X86-LABEL: test_powi_f64_i32:
8588
; GISEL-X86: # %bb.0:
86-
; GISEL-X86-NEXT: subl $12, %esp
87-
; GISEL-X86-NEXT: fldl {{[0-9]+}}(%esp)
88-
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
89-
; GISEL-X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
90-
; GISEL-X86-NEXT: fstpl (%esp)
89+
; GISEL-X86-NEXT: pushl %esi
90+
; GISEL-X86-NEXT: subl $24, %esp
91+
; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax
92+
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
93+
; GISEL-X86-NEXT: movl 4(%eax), %eax
94+
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %edx
95+
; GISEL-X86-NEXT: xorl %esi, %esi
96+
; GISEL-X86-NEXT: addl %esp, %esi
97+
; GISEL-X86-NEXT: movl %ecx, (%esp)
98+
; GISEL-X86-NEXT: movl %eax, 4(%esi)
99+
; GISEL-X86-NEXT: movl %edx, {{[0-9]+}}(%esp)
91100
; GISEL-X86-NEXT: calll __powidf2
92-
; GISEL-X86-NEXT: addl $12, %esp
101+
; GISEL-X86-NEXT: addl $24, %esp
102+
; GISEL-X86-NEXT: popl %esi
93103
; GISEL-X86-NEXT: retl
94104
;
95105
; FAST-X64-LABEL: test_powi_f64_i32:
@@ -105,7 +115,10 @@ define double @test_powi_f64_i32(double %Val, i32 %x) nounwind {
105115
;
106116
; GISEL-X64-LABEL: test_powi_f64_i32:
107117
; GISEL-X64: # %bb.0:
108-
; GISEL-X64-NEXT: jmp __powidf2@PLT # TAILCALL
118+
; GISEL-X64-NEXT: pushq %rax
119+
; GISEL-X64-NEXT: callq __powidf2
120+
; GISEL-X64-NEXT: popq %rax
121+
; GISEL-X64-NEXT: retq
109122
%res = call double @llvm.powi.f64.i32(double %Val, i32 %x)
110123
ret double %res
111124
}
@@ -138,8 +151,8 @@ define x86_fp80 @test_powi_f80_i32(x86_fp80 %Val, i32 %x) nounwind {
138151
; GISEL-X86-NEXT: subl $28, %esp
139152
; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
140153
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
141-
; GISEL-X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
142154
; GISEL-X86-NEXT: fstpt (%esp)
155+
; GISEL-X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
143156
; GISEL-X86-NEXT: calll __powixf2
144157
; GISEL-X86-NEXT: addl $28, %esp
145158
; GISEL-X86-NEXT: retl
@@ -167,7 +180,7 @@ define x86_fp80 @test_powi_f80_i32(x86_fp80 %Val, i32 %x) nounwind {
167180
; GISEL-X64-NEXT: subq $24, %rsp
168181
; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
169182
; GISEL-X64-NEXT: fstpt (%rsp)
170-
; GISEL-X64-NEXT: callq __powixf2@PLT
183+
; GISEL-X64-NEXT: callq __powixf2
171184
; GISEL-X64-NEXT: addq $24, %rsp
172185
; GISEL-X64-NEXT: retq
173186
%res = call x86_fp80 @llvm.powi.f80.i32(x86_fp80 %Val, i32 %x)

0 commit comments

Comments
 (0)