public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wouter dot vermaelen at scarlet dot be" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/32648]  New: missed-optimization: bit-manipulation via bool's
Date: Fri, 06 Jul 2007 12:25:00 -0000	[thread overview]
Message-ID: <bug-32648-8535@http.gcc.gnu.org/bugzilla/> (raw)

> cat b5-xor-b3.cc
bool f1(int a)
{
        bool b5 = a & 0x20;
        bool b3 = a & 0x08;
        return b5 ^ b3;
}
bool f2(int a)
{
        return (a ^ (a << 2)) & 0x20;
}

> g++ -O3 -c b5-xor-b3.cc
> objdump -d b5-xor-b3.o

b5-xor-b3.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <_Z2f1i>:
   0:   c1 ef 03                shr    $0x3,%edi
   3:   89 f8                   mov    %edi,%eax
   5:   c1 ef 02                shr    $0x2,%edi
   8:   83 e0 01                and    $0x1,%eax
   b:   83 e7 01                and    $0x1,%edi
   e:   40 38 f8                cmp    %dil,%al
  11:   0f 95 c0                setne  %al
  14:   0f b6 c0                movzbl %al,%eax
  17:   c3                      retq
  18:   0f 1f 84 00 00 00 00    nopl   0x0(%rax,%rax,1)
  1f:   00

0000000000000020 <_Z2f2i>:
  20:   8d 04 bd 00 00 00 00    lea    0x0(,%rdi,4),%eax
  27:   31 f8                   xor    %edi,%eax
  29:   c1 e8 05                shr    $0x5,%eax
  2c:   83 e0 01                and    $0x1,%eax
  2f:   c3                      retq


-- 
           Summary: missed-optimization: bit-manipulation via bool's
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wouter dot vermaelen at scarlet dot be


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


             reply	other threads:[~2007-07-06 12:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-06 12:25 wouter dot vermaelen at scarlet dot be [this message]
2007-07-06 12:54 ` [Bug tree-optimization/32648] " rguenth at gcc dot gnu dot org
2007-07-07  3:10 ` rob1weld at aol dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-32648-8535@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).