public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17969] New: template inline functions not getting optimized
@ 2004-10-13  6:11 pkprasoon at gmail dot com
  2004-10-13  6:14 ` [Bug c++/17969] " pkprasoon at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pkprasoon at gmail dot com @ 2004-10-13  6:11 UTC (permalink / raw)
  To: gcc-bugs

System: Linux columbia 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003 i686 i686 i386
GNU/Linux
Architecture: i686

$ gcc -v
Reading specs from /home/pkpras/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/specs
Configured with: ./configure --prefix=/home/pkpras/usr/local
Thread model: posix
gcc version 3.4.2


Below I am just showing the contents of two C++ files. I will be attaching *.i*
files later.

$ cat s1.cpp
#include <functional>

template <typename Op>
inline bool ff(Op op, int x)
{
  return op(x);
}

int f(int x)
{
  if (ff(std::bind2nd(std::equal_to<int>(), 10), x))
    return 0;
  else
    return 1;
}

$ cat s2.cpp
int f(int x)
{
  if (x == 10)
    return 0;
  else
    return 1;
}

The command line used for compiling the two files are as follows:
$ gcc -S -O3 s1.cpp 
$ gcc -S -O3 s2.cpp 

The file s1.s has more code than s2.s. Below is the diff:

$ diff s1.s s2.s
1c1
<       .file   "s1.cpp"
---
>       .file   "s2.cpp"
8,9c8
< .LFB86:
< .L3:
---
> .LFB2:
11a11
>       xorl    %eax, %eax
14,23c14,15
<       subl    $16, %esp
< .LCFI2:
<       movl    $10, -4(%ebp)
<       movl    -8(%ebp), %eax
<       movl    -4(%ebp), %ecx
<       movl    8(%ebp), %edx
<       movl    %eax, -16(%ebp)
<       movl    %ecx, -12(%ebp)
<       cmpl    -12(%ebp), %edx
<       leave
---
>       cmpl    $10, 8(%ebp)
>       popl    %ebp
25d16
<       movzbl  %al, %eax
27c18
< .LFE86:
---
> .LFE2:

It seems that bind2nd is not getting optimized adequately.

-- 
           Summary: template inline functions not getting optimized
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pkprasoon at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/17969] template inline functions not getting optimized
  2004-10-13  6:11 [Bug c++/17969] New: template inline functions not getting optimized pkprasoon at gmail dot com
@ 2004-10-13  6:14 ` pkprasoon at gmail dot com
  2004-10-13  6:15 ` pkprasoon at gmail dot com
  2004-10-13 11:38 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pkprasoon at gmail dot com @ 2004-10-13  6:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pkprasoon at gmail dot com  2004-10-13 06:14 -------
Created an attachment (id=7333)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7333&action=view)
file corresponding to s1.cpp


-- 


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


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

* [Bug c++/17969] template inline functions not getting optimized
  2004-10-13  6:11 [Bug c++/17969] New: template inline functions not getting optimized pkprasoon at gmail dot com
  2004-10-13  6:14 ` [Bug c++/17969] " pkprasoon at gmail dot com
@ 2004-10-13  6:15 ` pkprasoon at gmail dot com
  2004-10-13 11:38 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pkprasoon at gmail dot com @ 2004-10-13  6:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pkprasoon at gmail dot com  2004-10-13 06:15 -------
Created an attachment (id=7334)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7334&action=view)
file correspoding to s2.cpp


-- 


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


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

* [Bug c++/17969] template inline functions not getting optimized
  2004-10-13  6:11 [Bug c++/17969] New: template inline functions not getting optimized pkprasoon at gmail dot com
  2004-10-13  6:14 ` [Bug c++/17969] " pkprasoon at gmail dot com
  2004-10-13  6:15 ` pkprasoon at gmail dot com
@ 2004-10-13 11:38 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-13 11:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-13 11:38 -------
Fixed on the mainline:
        xori r3,r3,10
        subfic r0,r3,0
        adde r3,r0,r3
        xori r3,r3,1
        blr

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |missed-optimization
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2004-10-13 11:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-13  6:11 [Bug c++/17969] New: template inline functions not getting optimized pkprasoon at gmail dot com
2004-10-13  6:14 ` [Bug c++/17969] " pkprasoon at gmail dot com
2004-10-13  6:15 ` pkprasoon at gmail dot com
2004-10-13 11:38 ` 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).