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

2004-10-12 Thread pkprasoon at gmail dot com

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


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

2004-10-12 Thread pkprasoon at gmail dot com

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


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

2004-10-12 Thread pkprasoon at gmail dot com
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 

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

int f(int x)
{
  if (ff(std::bind2nd(std::equal_to(), 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
<   movl8(%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