This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/31096] a*C == b*C where C is a constant is not optimized to a == b
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Mar 2007 12:06:04 -0000
- Subject: [Bug middle-end/31096] a*C == b*C where C is a constant is not optimized to a == b
- References: <bug-31096-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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