[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress
Melanie Blower via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 09:33:19 PDT 2020
mibintc added inline comments.
================
Comment at: clang/test/CodeGen/fp-floatcontrol-pragma.cpp:154
+ if (i<0)
+ return 1.0 + 2.0;
+ // Check that floating point constant folding doesn't occur if
----------------
sepavloff wrote:
> In this particular case we know for sure that the result does not depend on rounding mode and no FP exceptions occurs, so it is safe to constfold the expression.
>
> Expressions like `1.0 / 0.0` or `1.0F + 0x0.000001p0F` indeed may require execution in runtime, depending on the required exception handling. I would propose to connect their const-evaluability with `FPExceptionMode` and set the latter to `strict` whenever `AllowFEnvAccess` is set to `true`.
Thank you, I will study these remarks. BTW I had inserted checks to verify semantic rules about the use of pragma float_control and fenv_access, to follow what Microsoft describes on this page, https://docs.microsoft.com/en-us/cpp/preprocessor/fenv-access?view=vs-2019
Quoting:
There are restrictions on the ways you can use the fenv_access pragma in combination with other floating-point settings:
You can't enable fenv_access unless precise semantics are enabled. Precise semantics can be enabled either by the float_control pragma, or by using the /fp:precise or /fp:strict compiler options. The compiler defaults to /fp:precise if no other floating-point command-line option is specified.
You can't use float_control to disable precise semantics when fenv_access(on) is set.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87528/new/
https://reviews.llvm.org/D87528
More information about the cfe-commits
mailing list