Skip to content

Commit 4c9f6a7

Browse files
[X86][GlobalISel] Enable Trigonometric functions with libcall mapping (#126931)
1 parent 20cea4d commit 4c9f6a7

File tree

11 files changed

+811
-404
lines changed

11 files changed

+811
-404
lines changed

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

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

102-
getActionDefinitionsBuilder(G_LROUND).libcall();
103-
104-
getActionDefinitionsBuilder(G_LLROUND).libcall();
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})
105+
.libcall();
105106

106107
// merge/unmerge
107108
for (unsigned Op : {G_MERGE_VALUES, G_UNMERGE_VALUES}) {

llvm/test/CodeGen/X86/llvm.acos.ll

Lines changed: 79 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,76 @@
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 -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
3-
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
4-
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
5-
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
3+
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=SDAG-X64
4+
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=X86,GISEL-X86
5+
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64
66

77
define float @use_acosf32(float %a) nounwind {
8-
; X86-LABEL: use_acosf32:
9-
; X86: # %bb.0:
10-
; X86-NEXT: subl $12, %esp
11-
; X86-NEXT: flds {{[0-9]+}}(%esp)
12-
; X86-NEXT: fstps (%esp)
13-
; X86-NEXT: calll acosf
14-
; X86-NEXT: addl $12, %esp
15-
; X86-NEXT: retl
8+
; SDAG-X86-LABEL: use_acosf32:
9+
; SDAG-X86: # %bb.0:
10+
; SDAG-X86-NEXT: subl $12, %esp
11+
; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
12+
; SDAG-X86-NEXT: fstps (%esp)
13+
; SDAG-X86-NEXT: calll acosf
14+
; SDAG-X86-NEXT: addl $12, %esp
15+
; SDAG-X86-NEXT: retl
1616
;
17-
; X64-LABEL: use_acosf32:
18-
; X64: # %bb.0:
19-
; X64-NEXT: jmp acosf@PLT # TAILCALL
17+
; SDAG-X64-LABEL: use_acosf32:
18+
; SDAG-X64: # %bb.0:
19+
; SDAG-X64-NEXT: jmp acosf@PLT # TAILCALL
20+
;
21+
; GISEL-X86-LABEL: use_acosf32:
22+
; GISEL-X86: # %bb.0:
23+
; GISEL-X86-NEXT: subl $12, %esp
24+
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
25+
; GISEL-X86-NEXT: movl %eax, (%esp)
26+
; GISEL-X86-NEXT: calll acosf
27+
; GISEL-X86-NEXT: addl $12, %esp
28+
; GISEL-X86-NEXT: retl
29+
;
30+
; GISEL-X64-LABEL: use_acosf32:
31+
; GISEL-X64: # %bb.0:
32+
; GISEL-X64-NEXT: pushq %rax
33+
; GISEL-X64-NEXT: callq acosf
34+
; GISEL-X64-NEXT: popq %rax
35+
; GISEL-X64-NEXT: retq
2036
%x = call float @llvm.acos.f32(float %a)
2137
ret float %x
2238
}
2339

2440
define double @use_acosf64(double %a) nounwind {
25-
; X86-LABEL: use_acosf64:
26-
; X86: # %bb.0:
27-
; X86-NEXT: subl $12, %esp
28-
; X86-NEXT: fldl {{[0-9]+}}(%esp)
29-
; X86-NEXT: fstpl (%esp)
30-
; X86-NEXT: calll acos
31-
; X86-NEXT: addl $12, %esp
32-
; X86-NEXT: retl
41+
; SDAG-X86-LABEL: use_acosf64:
42+
; SDAG-X86: # %bb.0:
43+
; SDAG-X86-NEXT: subl $12, %esp
44+
; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
45+
; SDAG-X86-NEXT: fstpl (%esp)
46+
; SDAG-X86-NEXT: calll acos
47+
; SDAG-X86-NEXT: addl $12, %esp
48+
; SDAG-X86-NEXT: retl
3349
;
34-
; X64-LABEL: use_acosf64:
35-
; X64: # %bb.0:
36-
; X64-NEXT: jmp acos@PLT # TAILCALL
50+
; SDAG-X64-LABEL: use_acosf64:
51+
; SDAG-X64: # %bb.0:
52+
; SDAG-X64-NEXT: jmp acos@PLT # TAILCALL
53+
;
54+
; GISEL-X86-LABEL: use_acosf64:
55+
; GISEL-X86: # %bb.0:
56+
; GISEL-X86-NEXT: subl $12, %esp
57+
; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax
58+
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
59+
; GISEL-X86-NEXT: movl 4(%eax), %eax
60+
; GISEL-X86-NEXT: xorl %edx, %edx
61+
; GISEL-X86-NEXT: addl %esp, %edx
62+
; GISEL-X86-NEXT: movl %ecx, (%esp)
63+
; GISEL-X86-NEXT: movl %eax, 4(%edx)
64+
; GISEL-X86-NEXT: calll acos
65+
; GISEL-X86-NEXT: addl $12, %esp
66+
; GISEL-X86-NEXT: retl
67+
;
68+
; GISEL-X64-LABEL: use_acosf64:
69+
; GISEL-X64: # %bb.0:
70+
; GISEL-X64-NEXT: pushq %rax
71+
; GISEL-X64-NEXT: callq acos
72+
; GISEL-X64-NEXT: popq %rax
73+
; GISEL-X64-NEXT: retq
3774
%x = call double @llvm.acos.f64(double %a)
3875
ret double %x
3976
}
@@ -48,23 +85,27 @@ define x86_fp80 @use_acosf80(x86_fp80 %a) nounwind {
4885
; X86-NEXT: addl $12, %esp
4986
; X86-NEXT: retl
5087
;
51-
; X64-LABEL: use_acosf80:
52-
; X64: # %bb.0:
53-
; X64-NEXT: subq $24, %rsp
54-
; X64-NEXT: fldt {{[0-9]+}}(%rsp)
55-
; X64-NEXT: fstpt (%rsp)
56-
; X64-NEXT: callq acosl@PLT
57-
; X64-NEXT: addq $24, %rsp
58-
; X64-NEXT: retq
88+
; SDAG-X64-LABEL: use_acosf80:
89+
; SDAG-X64: # %bb.0:
90+
; SDAG-X64-NEXT: subq $24, %rsp
91+
; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
92+
; SDAG-X64-NEXT: fstpt (%rsp)
93+
; SDAG-X64-NEXT: callq acosl@PLT
94+
; SDAG-X64-NEXT: addq $24, %rsp
95+
; SDAG-X64-NEXT: retq
96+
;
97+
; GISEL-X64-LABEL: use_acosf80:
98+
; GISEL-X64: # %bb.0:
99+
; GISEL-X64-NEXT: subq $24, %rsp
100+
; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
101+
; GISEL-X64-NEXT: fstpt (%rsp)
102+
; GISEL-X64-NEXT: callq acosl
103+
; GISEL-X64-NEXT: addq $24, %rsp
104+
; GISEL-X64-NEXT: retq
59105
%x = call x86_fp80 @llvm.acos.f80(x86_fp80 %a)
60106
ret x86_fp80 %x
61107
}
62108

63109
declare float @llvm.acos.f32(float)
64110
declare double @llvm.acos.f64(double)
65111
declare x86_fp80 @llvm.acos.f80(x86_fp80)
66-
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
67-
; GISEL-X64: {{.*}}
68-
; GISEL-X86: {{.*}}
69-
; SDAG-X64: {{.*}}
70-
; SDAG-X86: {{.*}}

llvm/test/CodeGen/X86/llvm.asin.ll

Lines changed: 79 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,76 @@
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 -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
3-
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
4-
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
5-
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
3+
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=SDAG-X64
4+
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=X86,GISEL-X86
5+
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64
66

77
define float @use_asinf32(float %a) nounwind {
8-
; X86-LABEL: use_asinf32:
9-
; X86: # %bb.0:
10-
; X86-NEXT: subl $12, %esp
11-
; X86-NEXT: flds {{[0-9]+}}(%esp)
12-
; X86-NEXT: fstps (%esp)
13-
; X86-NEXT: calll asinf
14-
; X86-NEXT: addl $12, %esp
15-
; X86-NEXT: retl
8+
; SDAG-X86-LABEL: use_asinf32:
9+
; SDAG-X86: # %bb.0:
10+
; SDAG-X86-NEXT: subl $12, %esp
11+
; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
12+
; SDAG-X86-NEXT: fstps (%esp)
13+
; SDAG-X86-NEXT: calll asinf
14+
; SDAG-X86-NEXT: addl $12, %esp
15+
; SDAG-X86-NEXT: retl
1616
;
17-
; X64-LABEL: use_asinf32:
18-
; X64: # %bb.0:
19-
; X64-NEXT: jmp asinf@PLT # TAILCALL
17+
; SDAG-X64-LABEL: use_asinf32:
18+
; SDAG-X64: # %bb.0:
19+
; SDAG-X64-NEXT: jmp asinf@PLT # TAILCALL
20+
;
21+
; GISEL-X86-LABEL: use_asinf32:
22+
; GISEL-X86: # %bb.0:
23+
; GISEL-X86-NEXT: subl $12, %esp
24+
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
25+
; GISEL-X86-NEXT: movl %eax, (%esp)
26+
; GISEL-X86-NEXT: calll asinf
27+
; GISEL-X86-NEXT: addl $12, %esp
28+
; GISEL-X86-NEXT: retl
29+
;
30+
; GISEL-X64-LABEL: use_asinf32:
31+
; GISEL-X64: # %bb.0:
32+
; GISEL-X64-NEXT: pushq %rax
33+
; GISEL-X64-NEXT: callq asinf
34+
; GISEL-X64-NEXT: popq %rax
35+
; GISEL-X64-NEXT: retq
2036
%x = call float @llvm.asin.f32(float %a)
2137
ret float %x
2238
}
2339

2440
define double @use_asinf64(double %a) nounwind {
25-
; X86-LABEL: use_asinf64:
26-
; X86: # %bb.0:
27-
; X86-NEXT: subl $12, %esp
28-
; X86-NEXT: fldl {{[0-9]+}}(%esp)
29-
; X86-NEXT: fstpl (%esp)
30-
; X86-NEXT: calll asin
31-
; X86-NEXT: addl $12, %esp
32-
; X86-NEXT: retl
41+
; SDAG-X86-LABEL: use_asinf64:
42+
; SDAG-X86: # %bb.0:
43+
; SDAG-X86-NEXT: subl $12, %esp
44+
; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
45+
; SDAG-X86-NEXT: fstpl (%esp)
46+
; SDAG-X86-NEXT: calll asin
47+
; SDAG-X86-NEXT: addl $12, %esp
48+
; SDAG-X86-NEXT: retl
3349
;
34-
; X64-LABEL: use_asinf64:
35-
; X64: # %bb.0:
36-
; X64-NEXT: jmp asin@PLT # TAILCALL
50+
; SDAG-X64-LABEL: use_asinf64:
51+
; SDAG-X64: # %bb.0:
52+
; SDAG-X64-NEXT: jmp asin@PLT # TAILCALL
53+
;
54+
; GISEL-X86-LABEL: use_asinf64:
55+
; GISEL-X86: # %bb.0:
56+
; GISEL-X86-NEXT: subl $12, %esp
57+
; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax
58+
; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
59+
; GISEL-X86-NEXT: movl 4(%eax), %eax
60+
; GISEL-X86-NEXT: xorl %edx, %edx
61+
; GISEL-X86-NEXT: addl %esp, %edx
62+
; GISEL-X86-NEXT: movl %ecx, (%esp)
63+
; GISEL-X86-NEXT: movl %eax, 4(%edx)
64+
; GISEL-X86-NEXT: calll asin
65+
; GISEL-X86-NEXT: addl $12, %esp
66+
; GISEL-X86-NEXT: retl
67+
;
68+
; GISEL-X64-LABEL: use_asinf64:
69+
; GISEL-X64: # %bb.0:
70+
; GISEL-X64-NEXT: pushq %rax
71+
; GISEL-X64-NEXT: callq asin
72+
; GISEL-X64-NEXT: popq %rax
73+
; GISEL-X64-NEXT: retq
3774
%x = call double @llvm.asin.f64(double %a)
3875
ret double %x
3976
}
@@ -48,23 +85,27 @@ define x86_fp80 @use_asinf80(x86_fp80 %a) nounwind {
4885
; X86-NEXT: addl $12, %esp
4986
; X86-NEXT: retl
5087
;
51-
; X64-LABEL: use_asinf80:
52-
; X64: # %bb.0:
53-
; X64-NEXT: subq $24, %rsp
54-
; X64-NEXT: fldt {{[0-9]+}}(%rsp)
55-
; X64-NEXT: fstpt (%rsp)
56-
; X64-NEXT: callq asinl@PLT
57-
; X64-NEXT: addq $24, %rsp
58-
; X64-NEXT: retq
88+
; SDAG-X64-LABEL: use_asinf80:
89+
; SDAG-X64: # %bb.0:
90+
; SDAG-X64-NEXT: subq $24, %rsp
91+
; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
92+
; SDAG-X64-NEXT: fstpt (%rsp)
93+
; SDAG-X64-NEXT: callq asinl@PLT
94+
; SDAG-X64-NEXT: addq $24, %rsp
95+
; SDAG-X64-NEXT: retq
96+
;
97+
; GISEL-X64-LABEL: use_asinf80:
98+
; GISEL-X64: # %bb.0:
99+
; GISEL-X64-NEXT: subq $24, %rsp
100+
; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
101+
; GISEL-X64-NEXT: fstpt (%rsp)
102+
; GISEL-X64-NEXT: callq asinl
103+
; GISEL-X64-NEXT: addq $24, %rsp
104+
; GISEL-X64-NEXT: retq
59105
%x = call x86_fp80 @llvm.asin.f80(x86_fp80 %a)
60106
ret x86_fp80 %x
61107
}
62108

63109
declare float @llvm.asin.f32(float)
64110
declare double @llvm.asin.f64(double)
65111
declare x86_fp80 @llvm.asin.f80(x86_fp80)
66-
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
67-
; GISEL-X64: {{.*}}
68-
; GISEL-X86: {{.*}}
69-
; SDAG-X64: {{.*}}
70-
; SDAG-X86: {{.*}}

0 commit comments

Comments
 (0)