public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46309] New: optimization a==3||a==1
@ 2010-11-05  8:36 eidletni at mail dot ru
  2010-11-05  8:37 ` [Bug c++/46309] " eidletni at mail dot ru
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: eidletni at mail dot ru @ 2010-11-05  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: optimization a==3||a==1
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: eidletni@mail.ru


$g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/eid-letni/opt/gcc/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/home/eid-letni/opt/gcc
--enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20101105 (experimental) (GCC) 

$uname -a
Linux eidletni 2.6.35-22-generic #35-Ubuntu SMP Sat Oct 16 20:36:48 UTC 2010
i686 GNU/Linux

$g++ -O3 -c main.ii

func good_comp have optimiz without jump:

bool good_comp(int a, int b)
{
    return (a==3)||(a==1);
}

asm with no jumps:

00000020 <_Z9good_compii>:
  20:    8b 54 24 04              mov    0x4(%esp),%edx
  24:    83 fa 01                 cmp    $0x1,%edx
  27:    0f 94 c0                 sete   %al
  2a:    83 fa 03                 cmp    $0x3,%edx
  2d:    0f 94 c2                 sete   %dl
  30:    09 d0                    or     %edx,%eax
  32:    c3                       ret    

using "same" code with temps:

bool bad_comp(int a, int b)
{
    bool tmp1 = (a==3);
    bool tmp2 = (a==1);
    return tmp1||tmp2;
}

asm(with jump):

00000000 <_Z8bad_compii>:
   0:    8b 54 24 04              mov    0x4(%esp),%edx
   4:    b8 01 00 00 00           mov    $0x1,%eax
   9:    83 fa 03                 cmp    $0x3,%edx
   c:    74 06                    je     14 <_Z8bad_compii+0x14>
   e:    83 fa 01                 cmp    $0x1,%edx
  11:    0f 94 c0                 sete   %al
  14:    f3 c3                    repz ret


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

end of thread, other threads:[~2012-10-31 22:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-05  8:36 [Bug c++/46309] New: optimization a==3||a==1 eidletni at mail dot ru
2010-11-05  8:37 ` [Bug c++/46309] " eidletni at mail dot ru
2010-11-06 18:55 ` svfuerst at gmail dot com
2011-09-23 22:54 ` paolo.carlini at oracle dot com
2011-09-24  9:57 ` [Bug tree-optimization/46309] " jakub at gcc dot gnu.org
2011-09-30 15:16 ` jakub at gcc dot gnu.org
2011-09-30 20:19 ` paolo.carlini at oracle dot com
2011-09-30 20:28 ` jakub at gcc dot gnu.org
2011-09-30 20:48 ` paolo.carlini at oracle dot com
2011-11-23  1:55 ` pinskia at gcc dot gnu.org
2012-10-31  8:46 ` jakub at gcc dot gnu.org
2012-10-31  8:55 ` jakub at gcc dot gnu.org
2012-10-31 19:10 ` eidletni at mail dot ru
2012-10-31 22:37 ` rdsandiford at googlemail dot com

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).