https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107608

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jsm28 at gcc dot gnu.org

--- Comment #23 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Sure, VRP and DOM etc. have been replacing operations with singleton results
for quite a while, but most of integer arithmetics don't cause exceptions which
one can test or handle through signals.  As has been said above, we have
-fdelete-dead-exceptions option and we might want to consider similar option
for the floating point traps.
Without VRP and similar optimizations, both have some chances to work fine, say
if I have:
void
foo (int *p, int *q)
{
  int r = *p + *q;
}
and -fdelete-dead-exceptions -fnon-call-exceptions, the *p and *q reads could
cause
an exception, but as user said -fdelete-dead-exceptions and nothing uses the
result,
it is fine not to dereference those.
A different question is:
int
bar (int *p, int *q)
{
  int pv = *p;
  int qv = *q;
  if (pv != 0) __builtin_unreachable ();
  if (qv != 0) __builtin_unreachable ();
  int r = pv + qv;
  return r;
}
Here we actually are using what has been read from the memory, so it is much
more fuzzy
if we can still claim the exceptions are dead.
And I think the frange vs. exceptions is exactly the same thing, though much
more often happening in real-world code.  So we'd need to figure out what the
definition for "contribute to the execution of the program" actually is...
With frange singleton folding, we could optimize tons of operations which each
could raise some exceptions, just because we could prove what the final result
would be.  Does that count as a use of those values or not?

Reply via email to