[PATCH] D127964: [DCE] Eliminate no-op atan and atan2 calls
Serge Pavlov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 15 06:16:29 PDT 2022
sepavloff added inline comments.
================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:3257-3260
+ case LibFunc_atan2:
+ case LibFunc_atan2f:
+ case LibFunc_atan2l:
+ return true;
----------------
mohammed-nurulhoque wrote:
> sepavloff wrote:
> > Both GLIBC and POSIX docs say that atan(0, 0) is 0. But C11 says (7.12.4.4p2):
> > ```
> > ... A domain error may occur if both arguments are zero.
> > ```
> > Could you please elaborate this question?
> The C11 still says the error is optional, so I think it's correct not to raise the error. Furthermore, POSIX docs say explicitly "If both arguments are 0, a domain error **shall not **occur."
> Other than that, out of these 3, POSIX descriptions look the most complete here, as it enumerates a lot of corner cases, whereas GLIBC & C docs are high-level, so I'm inclined to go with the POSIX description here.
Please put here a comment saying that POSIX, GLIBC and MSVC assume atan2(0, 0) is 0, C11 says that a domain error may occur but does not require that.
================
Comment at: llvm/test/Transforms/EarlyCSE/atan.ll:21
+entry:
+ %call = call float @atanf(float 0x7FF0000000000000)
+ ret float %call
----------------
Why it is not constfolded? C11 (F.10.1.3) states:
```
atan(±∞) returns ±π /2.
```
================
Comment at: llvm/test/Transforms/EarlyCSE/atan.ll:32
+entry:
+ %call = call float @atanf(float 0x7FF8000000000000)
+ ret float %call
----------------
Why it is not constfolded? C11 (F.10p11) states:
```
Functions with a NaN argument return a NaN result and raise no floating-point exception,
except where stated otherwise.
```
================
Comment at: llvm/test/Transforms/EarlyCSE/atan.ll:49
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float -0.000000e+00, float 0.000000e+00)
+; CHECK-NEXT: ret float -0.000000e+00
----------------
Why it is not removed? The value is not used and it should not have side effect, no?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127964/new/
https://reviews.llvm.org/D127964
More information about the llvm-commits
mailing list