In strict mode the 'roundin_mode' is set to 'dynamic'. Using this pragma to get out of strict mode doesn't have any effect on the 'rounding_mode'.
See https://godbolt.org/z/zoGTf4j1G
This patch fixes that.
Details
Diff Detail
Event Timeline
clang/test/CodeGen/pragma-fenv_access.c | ||
---|---|---|
243 | Should this be ignore? |
clang/lib/Sema/SemaAttr.cpp | ||
---|---|---|
1340 | 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. |
clang/test/CodeGen/pragma-fenv_access.c | ||
---|---|---|
243 | 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. |
clang/lib/Sema/SemaAttr.cpp | ||
---|---|---|
1340 | 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. |
The change makes more sense to me, thanks!
clang/test/CodeGen/pragma-fenv_access.c | ||
---|---|---|
243 | Maybe use float %0, float %1 to reduce unnecessary differences. |
clang/test/CodeGen/pragma-fenv_access.c | ||
---|---|---|
243 | Andy has noticed that the rest of the test is using the %, so to stay consistent I have put back the %. |
clang/test/CodeGen/pragma-fenv_access.c | ||
---|---|---|
4 | Why doesn't this case use STRICT-RND? round.tonearest, but I don't understand why. |
clang/test/CodeGen/pragma-fenv_access.c | ||
---|---|---|
4 | It does. I just forgot to add the ":" after the RUN. |
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.