This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/29186] optimzation breaks floating point exception flag reading
- From: "kreckel at ginac dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Nov 2006 22:23:08 -0000
- Subject: [Bug c/29186] optimzation breaks floating point exception flag reading
- References: <bug-29186-1882@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #17 from kreckel at ginac dot de 2006-11-06 22:23 -------
(In reply to comment #15)
> Maybe scheduling would have the same issue. The fact that the result of the
> division is not used is a red herring, though. Of course, the assumption is
> that it's actually used.
For the record: Andrew was right and above statement is wrong. The standard
explicitly mandates that unused code must not be removed unless the compiler
can determine that it cannot raise an exception flag [F.8.1]:
: Concern about side effects may inhibit code motion and removal of seemingly
: useless code. For example, in
: #include <fenv.h>
: #pragma STDC FENV_ACCESS ON
: void f(double x)
: {
: /* ... */
: for (i = 0; i < n; i++) x + 1;
: /* ... */
: }
: x + 1 might raise floating-point exceptions, so cannot be removed. And since
: the loop body might not execute (maybe 0 ³ n), x + 1 cannot be moved out of
: the loop. (Of course these optimizations are valid if the implementation can
: rule out the nettlesome cases.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29186