[llvm-dev] Reading FP Environment status from IR

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Thu May 6 09:21:02 PDT 2021


We have intrinsic versions of the floating point instructions to suppress
optimizations that are unsafe when exceptions are enabled.
https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics
Currently I think it prevents nearly all optimizations.

Clang should emit these for some targets like X86 when it sees #pragma STDC
FENV_ACCESS. Clang can only do this for targets that have implemented
proper support for the constrained intrinsics in the backend.

~Craig


On Thu, May 6, 2021 at 2:26 AM raghesh via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> Hi All,
>
> We would like to prevent certain optimizations (like hoisting an fdiv
> instruction) when the application has set the floating point environment
> flags using APIs like
> feraiseexcept
> <https://en.cppreference.com/w/cpp/numeric/fenv/feraiseexcept>  or if it
> uses  #pragma STDC FENV_ACCESS
> <https://en.cppreference.com/w/cpp/preprocessor/impl>.
>
> Is there any way to know this at LLVM-IR level?
>
> Regards,
> Raghesh
> ------------------------------
> Raghesh Aloor
> AMD India Pvt. Ltd.
> Bengaluru.
> ------------------------------
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210506/fb782d6d/attachment.html>


More information about the llvm-dev mailing list