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 middle-end/31096] a*C == b*C where C is a constant is not optimized to a == b



------- Comment #2 from joseph at codesourcery dot com  2007-03-09 12:06 -------
Subject: Re:   New: a*C == b*C where C is a constant
 is not optimized to a == b

On Fri, 9 Mar 2007, pinskia at gcc dot gnu dot org wrote:

> The following two functions should be equzlivant when overflow is undefined:
> int f(int a, int b)
> {
>   return a * 10 == b*10;
> }
> 
> int f1(int a, int b)
> {
>   return a==b;
> }

If the constant is odd, they are equivalent for wrapping (but not for 
trapping) and for unsigned as well.

(If the constant is 0, they aren't equivalent at all but the first should 
become "return 1;".)


-- 


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


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