| Issue |
58131
|
| Summary |
Reimplement basic optimizations with fenv_access
|
| Labels |
|
| Assignees |
|
| Reporter |
mglisse
|
Hello,
first, thanks a lot for implementing fenv_access!
While experimenting with it, I noticed that it still seems to aim for correctness only. For instance,
```c++
double f(double a){return a/2;}
```
generates with "Debian clang version 16.0.0-++20220928062542+48b8dee773f3-1~exp1" and options `-O3 -frounding-math`
```
movl $2, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
```
Since we use correctly rounded arithmetic for speed, this kind of code pessimization makes it less useful.
The IR looks like
```
%2 = tail call double @llvm.experimental.constrained.sitofp.f64.i32(i32 2, metadata !"round.dynamic", metadata !"fpexcept.ignore") #5
%3 = tail call double @llvm.experimental.constrained.fdiv.f64(double %0, double %2, metadata !"round.dynamic", metadata !"fpexcept.ignore") #5
```
Converting the constant 2 to `double` can be done at compile time, this is exact and the rounding mode has no impact. And replacing `x/2.` with `x*.5` is also safe whatever the current rounding mode.
Again, I understand giving correctness the priority, I just hope that some optimization can still happen.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs