public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Nathan Myers <ncm@itasoftware.com> To: gcc-gnats@gcc.gnu.org Cc: jimrees@itasoftware.com Subject: c++/6546: Optimization regression Date: Thu, 02 May 2002 22:26:00 -0000 [thread overview] Message-ID: <E173VZl-0003LQ-00@ipc> (raw) >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
reply other threads:[~2002-05-03 5:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=E173VZl-0003LQ-00@ipc \ --to=ncm@itasoftware.com \ --cc=gcc-gnats@gcc.gnu.org \ --cc=jimrees@itasoftware.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).