1 ; RUN: opt -passes=early-cse -S < %s | FileCheck %s
3 ; We allow either sign to provide flexibility for mathlib
4 ; implementations. The POSIX standard is not strict here.
6 define float @callatan0() {
7 ; CHECK-LABEL: @callatan0(
8 ; CHECK-NEXT: ret float {{-?}}0.000000e+00
10 %call = call float @atanf(float -0.0)
14 ; TODO: constant should be folded
15 define float @callatanInf() {
16 ; CHECK-LABEL: @callatanInf(
17 ; CHECK-NEXT: [[CALL:%.*]] = call float @atanf(float 0x7FF0000000000000)
18 ; CHECK-NEXT: ret float [[CALL]]
20 %call = call float @atanf(float 0x7FF0000000000000)
24 ; TODO: constant should be folded
25 define float @callatanNaN() {
26 ; CHECK-LABEL: @callatanNaN(
27 ; CHECK-NEXT: [[CALL:%.*]] = call float @atanf(float 0x7FF8000000000000)
28 ; CHECK-NEXT: ret float [[CALL]]
30 %call = call float @atanf(float 0x7FF8000000000000)
34 ; POSIX: May fail with Range Error. We choose not to fail.
35 define float @callatanDenorm() {
36 ; CHECK-LABEL: @callatanDenorm(
37 ; CHECK-NEXT: ret float 0x37A16C2000000000
39 %call = call float @atanf(float 0x37A16C2000000000)
43 ; TODO: long double calls currently not folded
44 define x86_fp80 @atanl_x86(x86_fp80 %x) {
45 ; CHECK-LABEL: @atanl_x86(
46 ; CHECK-NEXT: [[CALL:%.*]] = call x86_fp80 @atanl(x86_fp80 noundef 0xK3FFF8CCCCCCCCCCCCCCD)
47 ; CHECK-NEXT: ret x86_fp80 [[CALL]]
49 %call = call x86_fp80 @atanl(x86_fp80 noundef 0xK3FFF8CCCCCCCCCCCCCCD)
53 ; This is not folded because it is known to set errno on some systems.
55 define float @callatan2_00() {
56 ; CHECK-LABEL: @callatan2_00(
57 ; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float 0.000000e+00, float 0.000000e+00)
58 ; CHECK-NEXT: ret float [[CALL]]
60 %call = call float @atan2f(float 0.0, float 0.0)
64 ; This is not folded because it is known to set errno on some systems.
66 define float @callatan2_n00() {
67 ; CHECK-LABEL: @callatan2_n00(
68 ; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float -0.000000e+00, float 0.000000e+00)
69 ; CHECK-NEXT: ret float [[CALL]]
71 %call = call float @atan2f(float -0.0, float 0.0)
75 ; This is not folded because it is known to set errno on some systems.
77 define float @callatan2_0n0() {
78 ; CHECK-LABEL: @callatan2_0n0(
79 ; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float 0.000000e+00, float -0.000000e+00)
80 ; CHECK-NEXT: ret float [[CALL]]
82 %call = call float @atan2f(float 0.0, float -0.0)
86 ; This is not folded because it is known to set errno on some systems.
88 define float @callatan2_n0n0() {
89 ; CHECK-LABEL: @callatan2_n0n0(
90 ; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float -0.000000e+00, float -0.000000e+00)
91 ; CHECK-NEXT: ret float [[CALL]]
93 %call = call float @atan2f(float -0.0, float -0.0)
97 define float @callatan2_x0() {
98 ; CHECK-LABEL: @callatan2_x0(
99 ; CHECK-NEXT: ret float 0x3FF921FB60000000
101 %call = call float @atan2f(float 1.0, float -0.000000e+00)
105 define float @callatan2_0x() {
106 ; CHECK-LABEL: @callatan2_0x(
107 ; CHECK-NEXT: ret float -0.000000e+00
109 %call = call float @atan2f(float -0.0, float 1.0)
113 define float @callatan2_xx() {
114 ; CHECK-LABEL: @callatan2_xx(
115 ; CHECK-NEXT: ret float 0xBFE921FB60000000
117 %call = call float @atan2f(float -1.0, float 1.0)
121 define float @callatan2_denorm() {
122 ; CHECK-LABEL: @callatan2_denorm(
123 ; CHECK-NEXT: ret float 0x37A16C2000000000
125 %call = call float @atan2f(float 0x39B4484C00000000, float 1.0e+10)
129 define float @callatan2_flush_to_zero() {
130 ; CHECK-LABEL: @callatan2_flush_to_zero(
131 ; CHECK-NEXT: ret float 0.000000e+00
133 %call = call float @atan2f(float 0x39B4484C00000000, float 0x4415AF1D80000000)
137 define float @callatan2_NaN() {
138 ; CHECK-LABEL: @callatan2_NaN(
139 ; CHECK-NEXT: ret float 0x7FF8000000000000
141 %call = call float @atan2f(float 0x7FF8000000000000, float 0x7FF8000000000000)
145 define float @callatan2_Inf() {
146 ; CHECK-LABEL: @callatan2_Inf(
147 ; CHECK-NEXT: ret float 0x3FE921FB60000000
149 %call = call float @atan2f(float 0x7FF0000000000000, float 0x7FF0000000000000)
153 declare dso_local float @atanf(float) #0
154 declare dso_local x86_fp80 @atanl(x86_fp80) #0
156 declare dso_local float @atan2f(float, float) #0
158 attributes #0 = { nofree nounwind willreturn }