public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/6546: Optimization regression
@ 2002-05-02 22:26 Nathan Myers
  0 siblings, 0 replies; only message in thread
From: Nathan Myers @ 2002-05-02 22:26 UTC (permalink / raw)
  To: gcc-gnats; +Cc: jimrees


>Number:         6546
>Category:       c++
>Synopsis:       static const members optimization failure
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Thu May 02 22:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Nathan Myers
>Release:        3.1 20020422 (prerelease)
>Organization:
ITA Software
>Environment:
>Description:
  The compiler fails to elide loading the value of a static const class 
  member initialized in the class definition when passing it to a function 
  that takes a const& to that type.  This is a regression from 2.95.

  In particular, it fails to generate a compare-immediate operation,
  instead loading the value from main memory.

>How-To-Repeat:
  struct Foo { static const int maxSegments = 10; };
  template< typename T > 
    inline const T& amin(const T& t1, const T& t2) { return t2 < t1 ? t2 : t1; }
  template< typename T > 
    inline T bmin(const T& t1, const T& t2) { return t2 < t1 ? t2 : t1; }
  
  int do_something(int argument)
  {
    return amin(argument, Foo::maxSegments) + bmin(argument, Foo::maxSegments);
  }
  const int Foo::maxSegments;

  $ gcc -S -O3 bug.cc 

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
 >System: Linux ipc 2.4.19-pre4 #3 SMP Fri Mar 29 02:57:10 EST 2002 i686 unknown
 >Architecture: i686
 >host: i686-pc-linux-gnu
 >build: i686-pc-linux-gnu
 >target: i686-pc-linux-gnu
 >configured with: ../gcc-3.1/configure --enable-languages=c++ --enable-threads=posix --prefix=/ncm/gnu-3.1 --enable-concept-checks


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-05-03  5:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-02 22:26 c++/6546: Optimization regression Nathan Myers

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