This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/19723] [4.0 Regression] A side effect is missed in 0 % a++.


------- Additional Comments From kazu at cs dot umass dot edu  2005-02-01 13:46 -------
Subject: Re:  [4.0 Regression] A side effect
 is missed in 0 % a++.

Hi Richard,

> > +       /* 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.
> 
> The only check you have at this level for this is integer_nonzerop.

Err, if this is the case, we have to disable the equivalent
optimization at RTL level.  Even if you disable this tree-level
optimization, CSE still simplifies the following to "return 0;".

int
foo (int a)
{
  return 0 % a;
}

Kazu Hirata


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19723


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]