update "optimizer inadequacies"

Zack Weinberg zackw@panix.com
Mon Aug 27 17:12:00 GMT 2001


On Mon, Aug 27, 2001 at 09:47:31AM -0700, Richard Henderson wrote:
> On Sat, Aug 25, 2001 at 04:25:01PM -0400, Zack Weinberg wrote:
> > For another, what are those trailing <code>andl</code>
> > instructions doing there?</p>
> 
> To zero-extend the "al" to "eax".  I think combine thought it
> was being clever reducing the number of bits in the mask.

oops, I had missed that eax wasn't previously cleared.

> > Optimal code for this example would look something like:
> > 
> > and:
> >         movl    4(%esp), %edx
> >         movl    8(%esp), %ecx
> >         xorl    %eax, %eax
> >         testl   %ecx, %edx
> >         setne   %al
> >         ret
> 
> Um, no.  (a && b) != (a & b).

Um, the whole point of this example is that under certain conditions
it's okay to optimize (a && b) into (a & b), and even desirable if
testing b is cheaper than a branch.

and the SETcc instructions set to 0 or 1, not 0 or -1.

zw



More information about the Gcc-patches mailing list