This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: CSE not combining equivalent expressions.
- From: Mircea Namolaru <NAMOLARU at il dot ibm dot com>
- To: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Cc: gcc at gcc dot gnu dot org, pranav dot bhandarkar at gmail dot com
- Date: Wed, 17 Jan 2007 18:23:45 +0200
- Subject: Re: CSE not combining equivalent expressions.
kenner@vlsi1.ultra.nyu.edu (Richard Kenner) wrote on 17/01/2007 18:04:20:
> > First, it seems to me that in your case:
> >
> > (1) a = a | 1 /* a |= 1 */
> > (2) a = a | 1 /* a |= 1 */
> >
> > the expressions "a | 1" in (1) and (2) are different as the "a"
> > is not the same. So there is nothing to do for CSE.
>
> It's not a CSE issue, but after (1), you know that the low-order bit of
> "a" is a one, so that (2) is a no-op. Note that the similar
> a &= ~1;
> a &= ~1;
>
> we do catch in combine.
>
> It could also be caught by converting
>
> a = ((a | 1) | 1);
>
> into
>
> a = (a | (1 | 1));
>
Yes, you are right if (1) and (2) are in the same basic block.
But the initial example that started this thread looks like:
a |= 1;
if (*x) ...
a }= 1;
so (1) and (2) are in two separate basic blocks. I think that
in this case combine doesn't work.
Mircea