This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17969] New: template inline functions not getting optimized


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]