[llvm] [FPEnv] Add strictfp attribute to the FP environment manipulation intrinsics (PR #96093)

Serge Pavlov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 10:59:49 PDT 2024


spavloff wrote:

> It would be bad if non-strictfp functions were forbidden from calling strictfp functions because of how the attributes API works. For starters, we have at least one test in tree already that has a non-strictfp function calling a strictfp function. I had to loosen the rules to get that test to pass, and I believe that loosening the rules was (and is) correct. It would be weird if strictfp functions could call non-strictfp functions by adding the attribute at a call site, but non-strictfp functions were forbidden from calling strictfp functions.

Strictfp set on a function call means, according to the documentation, that the context requires strictfp semantics, that is all FP operations, that normally look as pure functions, are required expose their  interaction with FP environment. It is OK for a functions that modify FP environment, like `fesetround`. If a function temporarily sets a non-default rounding mode to makes some calculation, it does not need the strict floating-point semantics in the context where it is called. In the latter case `strictfp` is implementation detail which does not need to be known outside the function body.

Unconditional propagation of strictfp from function declaration to function call does not look correct. 


https://github.com/llvm/llvm-project/pull/96093


More information about the llvm-commits mailing list