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

Andy Kaylor via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 7 10:02:00 PDT 2023


andrew.w.kaylor added inline comments.


================
Comment at: clang/test/CodeGen/pragma-fenv_access.c:239
+// CHECK-LABEL: @func_20
+// STRICT: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+// DEFAULT: fadd float
----------------
pengfei wrote:
> Should this be `ignore`?
This is a tricky case. By a strict reading of the C standard, this could be ignore, because the standard says the compiler can assume the default floating point environment when FENV_ACCESS is OFF and that if code compiled with FENV_ACCESS OFF is executed with anything other than the default environment the behavior is undefined. However, in this case strict exception semantics have been enabled elsewhere in the compilation unit, so floating point exceptions may be unmasked. The standard allows us to ignore exceptions, but raising a spurious exception may be bad for users.

I'm unsure about this case. I lean towards leaving it as Zahira has it here because I don't think the use of strict exception semantics will be common enough to justify the less conservative behavior.


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

https://reviews.llvm.org/D147733



More information about the cfe-commits mailing list