public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/17931] New: andl and testb are not combined
@ 2004-10-11 13:52 kazu at cs dot umass dot edu
  2004-10-11 13:54 ` [Bug rtl-optimization/17931] " kazu at cs dot umass dot edu
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-10-11 13:52 UTC (permalink / raw)
  To: gcc-bugs

Consider:

struct flags {
  unsigned f0 : 1;
  unsigned f1 : 1;
};

_Bool
foo (struct flags *p)
{
  if (p->f0)
    return 1;

  return p->f1;
}

With "cc1 -O2 -fomit-frame-pointer", I get

foo:
	movl	4(%esp), %eax
	movb	(%eax), %dl
	movb	%dl, %al
	andl	$1, %eax
	testb	%al, %al
	jne	.L7
	xorl	%eax, %eax
	testb	$2, %dl
	setne	%al
	ret
	.p2align 2,,3
.L7:
	movl	$1, %eax
	ret

Note that andl and testb are not combined to "testb $1, %al".
If they were combined, we would not destroy %eax,
so we would not need to make a copy of %al for a later use.

With -march=pentium4 or -march=athlon-xp, I get a similar result.

-- 
           Summary: andl and testb are not combined
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-10-12 17:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-11 13:52 [Bug rtl-optimization/17931] New: andl and testb are not combined kazu at cs dot umass dot edu
2004-10-11 13:54 ` [Bug rtl-optimization/17931] " kazu at cs dot umass dot edu
2004-10-11 14:01 ` pinskia at gcc dot gnu dot org
2004-10-11 14:06 ` pinskia at gcc dot gnu dot org
2004-10-11 14:12 ` [Bug rtl-optimization/17931] [4.0 Regresion] " pinskia at gcc dot gnu dot org
2004-10-11 14:47 ` [Bug rtl-optimization/17931] [4.0 Regression] " kazu at cs dot umass dot edu
2004-10-11 15:32 ` kazu at cs dot umass dot edu
2004-10-12 14:11 ` kazu at cs dot umass dot edu
2004-10-12 17:22 ` cvs-commit at gcc dot gnu dot org
2004-10-12 17:57 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).