This is the mail archive of the 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
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;
    return 1;

$ cat s2.cpp
int f(int x)
  if (x == 10)
    return 0;
    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
<       .file   "s1.cpp"
>       .file   "s2.cpp"
< .LFB86:
< .L3:
> .LFB2:
>       xorl    %eax, %eax
<       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
<       movzbl  %al, %eax
< .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

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