[PATCH] D147733: Set rounding_mode to tonearest in presence of a #pragma STDC FENV_ACCESS OFF.

Zahira Ammarguellat via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 7 10:46:12 PDT 2023


zahiraam added inline comments.


================
Comment at: clang/lib/Sema/SemaAttr.cpp:1340
+  if (!IsEnabled)
+    NewFPFeatures.setDisallowFenvAccess(IsEnabled);
   FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
----------------
andrew.w.kaylor wrote:
> Why is this only needed for "!IsEnabled"? Where is the rounding mode set in the IsEnabled case? It looks like setAllowFEnvAccessOverride() is defined by a macro and just sets a bit in the OverrideMask, but somehow it seems to be setting the rounding mode to Round.Dynamic. I'm just concerned that there is a disconnect in the implementation here.
That all depends on if we are using the -frounding-math in the command line option or not. The LIT test that exercices the pragma is not using this option so it's actually not testing the pragma in a strict mode. Using -ffp-model=strict trigger -frounding-math **and** -ffp-exception-behavior=strict.

I think I want to make this change only when we are in real strict mode. Meaning we need both of these options to be set.
#pragma STDC FENV_ACCESS OFF should trigger the round.tonearest when both these options are used. So when IsEnabled is false and RoundingMath is 1.


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

https://reviews.llvm.org/D147733



More information about the cfe-commits mailing list