public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/55023] New: hppa: wrong code generated with tail call optimisation
@ 2012-10-22 14:39 mans at mansr dot com
  2014-11-06  3:00 ` [Bug target/55023] " danglin at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: mans at mansr dot com @ 2012-10-22 14:39 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-01-08 21:30 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-22 14:39 [Bug target/55023] New: hppa: wrong code generated with tail call optimisation mans at mansr dot com
2014-11-06  3:00 ` [Bug target/55023] " danglin at gcc dot gnu.org
2014-11-06  3:01 ` danglin at gcc dot gnu.org
2014-11-06  3:09 ` danglin at gcc dot gnu.org
2014-11-07 22:13 ` law at redhat dot com
2014-11-07 22:23 ` dave.anglin at bell dot net
2014-11-07 22:24 ` law at redhat dot com
2014-11-09 17:54 ` dave.anglin at bell dot net
2014-11-10  2:50 ` dave.anglin at bell dot net
2014-11-10  5:48 ` law at redhat dot com
2014-11-22 16:20 ` danglin at gcc dot gnu.org
2014-11-22 16:22 ` danglin at gcc dot gnu.org
2014-11-23 19:01 ` danglin at gcc dot gnu.org
2014-11-24  0:22 ` danglin at gcc dot gnu.org
2014-12-22 23:10 ` danglin at gcc dot gnu.org
2015-01-08 21:30 ` jakub at gcc dot gnu.org

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).