[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
Wed Sep 16 14:29:10 PDT 2020
mibintc added inline comments.
================
Comment at: clang/lib/AST/ExprConstant.cpp:13197-13198
assert(E->isRValue() && E->getType()->isRealFloatingType());
+ if (Info.isStrictFP)
+ return false;
return FloatExprEvaluator(Info, Result).Visit(E);
----------------
rsmith wrote:
> I think we should be able to evaluate (for example) `constexpr float f = 1.0f;` even in a strict FP context. I think only floating point operations that depend on the rounding mode should be disabled, not all floating-point evaluation. Perhaps we should propagate the `FPOptions` into `handleFloatFloatBinOp` and perform the check there, along with any other places that care (I think we probably have some builtins that we can constant-evaluate that care about rounding modes.)
>
> You also need to produce a diagnostic when you treat an expression as non-constant -- please read the comment at the top of the file for details.
> I think we should be able to evaluate (for example) `constexpr float f = 1.0f;` even in a strict FP context. I think only floating point operations that depend on the rounding mode should be disabled, not all floating-point evaluation. Perhaps we should propagate the `FPOptions` into `handleFloatFloatBinOp` and perform the check there, along with any other places that care (I think we probably have some builtins that we can constant-evaluate that care about rounding modes.)
>
> You also need to produce a diagnostic when you treat an expression as non-constant -- please read the comment at the top of the file for details.
It's not just rounding mode, right? If fp exceptions are unmasked then we should inhibit the folding in particular cases?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87528/new/
https://reviews.llvm.org/D87528
More information about the cfe-commits
mailing list