[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 19 21:19:22 PDT 2024


spavloff wrote:

It is OK for the functions that modify FP environment. The case of the function that only read it is more debatable.

The LLVM Language Reference Manual defines `strictfp` as
```
This attribute indicates that the function was called from a scope that requires strict floating-point semantics.
```

There is no definition of the scopes that require this `strict floating-point semantics`, but it looks reasonable to associate them with the C language code regions where pragma FENV_ACCESS is ON. The pragma is used for (https://www.iso-9899.info/n3047.html#7.6.1p2):

```
The FENV_ACCESS pragma provides a means to inform the implementation when a program might
access the floating-point environment to test floating-point status flags or run under non-default
floating-point control modes.
```

Functions like `get_rounding` do not read status flags and do not set non-default control modes, so using them does not require FENV_ACCESS to be set. It is OK to use them in the default FP environment as they do not require the specific ordering restrictions that pragma FENV_ACCESS is proposed to set up.


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


More information about the llvm-commits mailing list