From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20593 invoked by alias); 23 Nov 2012 14:08:55 -0000 Received: (qmail 20216 invoked by uid 48); 23 Nov 2012 14:07:37 -0000 From: "jens.maurer at gmx dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/39102] gcc generating multiple stack stores in optimised code Date: Fri, 23 Nov 2012 14:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jens.maurer at gmx dot net X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-11/txt/msg02187.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39102 --- Comment #2 from Jens Maurer 2012-11-23 14:07:34 UTC --- Here is another test case: struct S { unsigned char * p; unsigned char * limit; }; S g(S s); inline __attribute__((always_inline)) S f(S s, unsigned int n); S f(S s, unsigned int n) { if (__builtin_expect(s.p + n < s.limit, 1)) { s.p += n; return s; } return g(s); } extern S sext; int main() { S s = sext; s = f(s, 4); s = f(s, 8); s = f(s, 2); return (int)(unsigned long)s.p; } leading to movq %rax, (%rsp) movq %rdx, 8(%rsp) in the code paths calling g(s), although "s" is kept in registers throughout.