| Issue |
173267
|
| Summary |
llvm.log/log2/log10 of 0 does not constant fold
|
| Labels |
missed-optimization,
floating-point
|
| Assignees |
|
| Reporter |
arsenm
|
https://godbolt.org/z/ehbP4z534
This does not fold out:
```
define float @fold_log2_0() {
%fold = call float @llvm.log2.f32(float 0.0)
ret float %fold
}
```
ConstantFoldFP gives up on this since this raises an exception in the host libcall:
```
2142 double Result = NativeFP(Input.convertToDouble());
2143 if (llvm_fenv_testexcept()) {
-> 2144 llvm_fenv_clearexcept();
2145 return nullptr;
2146 }
```
The constant folding should not care about exceptions. If anything this logic is backwards; it makes more sense to only constant fold the exact special cases of 0, 1 and infinity than rely on the host library implementation
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs