From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3116 invoked by alias); 27 Jul 2013 21:02:11 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 3059 invoked by uid 48); 27 Jul 2013 21:02:08 -0000 From: "dushistov at mail dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/58005] missed optimization printf constant string Date: Sat, 27 Jul 2013 21:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: dushistov at mail dot ru X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-07/txt/msg01351.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58005 --- Comment #4 from Evgeniy Dushistov --- >Such an optimization can increase code size >if the same format string is used with >many different arguments, may be then two fputs calls? fputs(__PRETTY_FUNCTION__, stdout); fputs("%s: test1\n" + 2/*skip format*/, stdout); yeah, still we have two calls vs one(bad for -Os), but we not introduce new string constants, so it is suitable optimization for -Ofast. In such test: for (int i = 0; i < 100000; ++i) { #ifdef OPTIMIZATION fputs(__PRETTY_FUNCTION__, stdout); fputs("%s: test1\n" + 2, stdout); #else printf("%s: test1\n", __PRETTY_FUNCTION__); #endif } fputs win with real 0m0.005s user 0m0.000s sys 0m0.000s vs printf real 0m0.011s user 0m0.010s sys 0m0.000s