This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/55023] New: hppa: wrong code generated with tail call optimisation
- From: "mans at mansr dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 22 Oct 2012 14:39:08 +0000
- Subject: [Bug target/55023] New: hppa: wrong code generated with tail call optimisation
- Auto-submitted: auto-generated
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