| Issue |
64653
|
| Summary |
pragma clang fp contract(fast) does not emit contract flags on calls compared to -ffp-contract=fast
|
| Labels |
clang:codegen,
floating-point
|
| Assignees |
|
| Reporter |
arsenm
|
Enabling fast contract with the pragma misses setting contract flags in some contexts (at a minimum, seems to not apply to any call). They are set if you use the global command line flag.
```
// clang -fno-math-errno -x c -O3 -S -emit-llvm
// clang -fno-math-errno -ffp-contract=fast -x c -O3 -S -emit-llvm
#include <math.h>
float enable_contract_fast_basic_ops(float x, float y, float z){
#pragma clang fp contract(fast)
x *= y;
x += z;
x /= z;
return x;
}
// contract missing from sqrtf call with only the pragma
// contract is present when using -ffp-contract=fast
float enable_contract_fast_sqrt_call(float x, float y) {
#pragma clang fp contract(fast)
return x / sqrtf(y);
}
float enable_contract_fast_builtin_sqrt_call(float x, float y) {
#pragma clang fp contract(fast)
return x / __builtin_sqrtf(y);
}
```
For example in this last function, with only the pragma I see:
```
define dso_local float @enable_contract_fast_builtin_sqrt_call(float noundef %0, float noundef %1) local_unnamed_addr #1 {
%3 = tail call float @llvm.sqrt.f32(float %1) ; missing contract flag
%4 = fdiv contract float %0, %3
ret float %4
}
```
Using -ffp-contract=fast:
```
define dso_local float @enable_contract_fast_builtin_sqrt_call(float noundef %0, float noundef %1) local_unnamed_addr #1 {
%3 = tail call contract float @llvm.sqrt.f32(float %1) ; contract correctly set on everything
%4 = fdiv contract float %0, %3
ret float %4
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs