[PATCH] D69272: Enable '#pragma STDC FENV_ACCESS' in frontend

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 14 09:02:36 PDT 2020


sepavloff added a comment.

In D69272#2268337 <https://reviews.llvm.org/D69272#2268337>, @mibintc wrote:

> I am working on a task to ensure that clang is doing floating point constant folding correctly.

Could you please share your plans on it? I recently also started implementing constant folding in `ExprConstant.cpp`. I have not made anything substantial yet, so I can easily switch to another task. Do you have any estimation when you could prepare the first version of the patch?

> But sometimes, if the floating point semantics are set to 'strict', even tho' folding has occurred successfully in ExprConstant.cpp, when i look at emit-llvm, there is arithmetic emitted for the floating point expression;

I used a bit different approach, may be it could be useful for you too. An initializer for global variable must be a constant, so things like `const xxx = 1.0 + 2.0` are evaluated. No llvm arithmetic occurs in the resulting ll file. Using `pragma STDC FENV_ROUND` floating point environment may be set to non-default state, which constant evaluator must use.

In D69272#2268387 <https://reviews.llvm.org/D69272#2268387>, @kpn wrote:

> Say, in D80952 <https://reviews.llvm.org/D80952> I added support for disabling strictfp support when a target doesn't support it. But it only applies to command line arguments.
>
> Is there any chance at all that relevant pragmas can also be disabled with the warning in the same cases?

This is definitely a good idea.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69272/new/

https://reviews.llvm.org/D69272



More information about the cfe-commits mailing list