[llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html

Eli Friedman eli.friedman at gmail.com
Mon May 4 01:31:43 PDT 2009


On Mon, May 4, 2009 at 12:42 AM, Duncan Sands <baldrick at free.fr> wrote:
> Is it valid
> to delete a divide by zero if the result has no uses?

Yes, it is valid; division by zero is undefined behavior, so it can do
anything; we make no attempt to preserve any traps from that.  For
example, we optimize x/x to 1 (where x is an integer).  Besides, even
if we did try to preserve the trap, depending on a trap isn't
portable; for example, the PowerPC division instruction never traps.

> If so, is it valid to delete a readonly call even if it may throw
> an exception?

No, it is not valid; throwing an exception is well-defined behavior.
(Of course, assuming throwing an exception from a readonly call is
legal.)

-Eli




More information about the llvm-commits mailing list