This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug tree-optimization/19723] [4.0 Regression] A side effectis missed in 0 % a++.
- From: Jeffrey A Law <law at redhat dot com>
- To: Richard Henderson <rth at gcc dot gnu dot org>
- Cc: gcc-bugzilla at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 01 Feb 2005 07:49:16 -0700
- Subject: Re: [Bug tree-optimization/19723] [4.0 Regression] A side effectis missed in 0 % a++.
- Organization: Red Hat, Inc
- References: <20050131134136.19723.kazu@cs.umass.edu> <20050131173323.22919.qmail@sourceware.org> <1107229535.20928.22.camel@localhost.localdomain> <20050201063622.GA4655@redhat.com>
- Reply-to: law at redhat dot com
On Mon, 2005-01-31 at 22:36 -0800, Richard Henderson wrote:
> On Mon, Jan 31, 2005 at 08:45:34PM -0700, Jeffrey A Law wrote:
> > + /* X % 0, return X % 0 unchanged so that we can get the
> > + proper warnings and errors. */
> > if (integer_zerop (arg1))
> > return t;
> >
> > + /* 0 % X is always zero, but be sure to preserve any side
> > + effects in X. Place this after checking for X == 0. */
> > + if (integer_zerop (arg0))
> > + return omit_one_operand (type, integer_zero_node, arg1);
>
> Not ok yet. You have to *know* that arg1 is not zero. Otherwise
> you're still potentially removing a division-by-zero.
Would would mean that we really can't do anything with DIV/MOD when
the numerator is a constant and the denominator is an unknown.
What I think we really want is to know whether or not the language
requires trapping on a DIV/MOD by zero. If so, then disable this class
of optimizations, otherwise we have a non-conformant program.
jeff