This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Should dead stores which could trap be deleted?
- To: amylaar at cygnus dot co dot uk
- Subject: Re: Should dead stores which could trap be deleted?
- From: John Wehle <john at feith dot com>
- Date: Fri, 6 Aug 1999 21:32:36 -0400 (EDT)
- Cc: gcc at gcc dot gnu dot org
>> when compiled -O2 on x86 due to dead_trivially_dead_insns. Consider
>> the situation where b equals 0 which on the x86 normally causes a
>> divide by zero exception. What are the guidelines regarding instructions
>> which could trap / to what extent is it valid for optimizations to modify
>> the behaviour of a program with respect to traps?
>
> A division by zero invokes undefined behaviour, hence gcc may do anything
> it likes with it.
The routine in question isn't special casing division by zero which
I am merely using as an example of something which can trap. Another
example is floating point math which also can trap. Interestingly enough
may_trap_p does have a specific check for potential division by zero.
Can a generalization be made that gcc is free to perform optimizations
which eliminates instructions that can trap so long that the resulting
code produces the right answer in any situation where the trap would
not have occurred? Or is each situation unique and a healthy dose
of common sense required?
Are traps which are important (and should not "disappear" unexpectedly)
indicated in the rtl by using trap_if?
-- John
PS: At a (very) quick glance I didn't see in rtl.texi where division
by zero was stated as being undefined. :-)
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------