Create a quiet floating-point comparision if function has strictfp attribute.
Avoid unexpected FP exception raised during libcall domain error checking.
It raises an FP exception only in case where an input is a signaling NaN.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
FP exceptions aren't supposed to matter in the default FP environment. This will create extra code on RISC-V that doesn't have quiet comparisons.
We shouldn't be generating calls to constrained FP functions unless we're in a function marked strictfp. And we don't care about exceptions outside such functions.
Do we actually run this code for strictfp functions? If we do, I guess we need to adjust it, but we need testcases.
The testcase look like
volatile double d; d = __builtin_nan (""); feclearexcept (FE_ALL_EXCEPT); acos(d) if (fetestexcept (FE_ALL_EXCEPT)) // expect no fp exception raised abort();
acos(d) emits extra two floating comparision that raise fp exception when a input is quiet NaN.
Something like https://godbolt.org/z/Yn31Tfoc4 ?
You need to add a check along the lines of if (BBBuilder.GetInsertBlock()->getParent()->hasFnAttribute(Attribute::StrictFP)) so this doesn't affect functions that aren't marked strictfp. Or maybe we should just disable the whole pass if the function is StrictFP?
Only set IsFPConstrained is true if function with attribute strictfp.
Also add testcase from my example program.