From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21997 invoked by alias); 22 Oct 2012 14:39:26 -0000 Received: (qmail 21922 invoked by uid 48); 22 Oct 2012 14:39:09 -0000 From: "mans at mansr dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/55023] New: hppa: wrong code generated with tail call optimisation Date: Mon, 22 Oct 2012 14:39:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mans at mansr dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: 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-10/txt/msg01977.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55023 Bug #: 55023 Summary: hppa: wrong code generated with tail call optimisation Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned@gcc.gnu.org ReportedBy: mans@mansr.com The following code is compiled incorrectly with flags -O2 -fno-inline: the third argument to the tail called function is not computed at all. This problem is present in all versions since 4.3. 4.1 and 4.2 compile it correctly. The error -fno-inline flag is needed to suppress inlining of the called function; when inlined it is compiled correctly. Providing only an external declaration for foo() also gives correct results. ---8<--- typedef long long int64_t; struct foo { int x; int y; }; int64_t foo(int64_t a, int64_t b, int64_t c) { return a + b + c; } int64_t bar(int64_t a, struct foo bq, struct foo cq) { int64_t b = bq.x + bq.y; int64_t c = cq.x + cq.y; return foo(a, b, c); } --->8--- This is the generated code: .align 4 .globl bar .type bar, @function bar: .PROC .CALLINFO FRAME=0,NO_CALLS,SAVE_RP .ENTRY stw %r23,-48(%r30) stw %r24,-44(%r30) ldw -44(%r30),%r28 stw %r2,-20(%r30) ldw -48(%r30),%r24 addl %r24,%r28,%r24 extrs %r24,0,1,%r23 ldw -20(%r30),%r2 bl foo,%r0 nop nop .EXIT .PROCEND