🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #54287

gcc optimisation

#54287
From: Patrick Sanchez
Date: Mon, 26 Nov 1990 11:59
92 lines
2555 bytes
I have got gcc 1.37.1 on a sun3 whith sunOS 4.03
While looking at the assembler source produced by the compiler,
I saw this

here is my example: (c source)
---------------- boucle.c ------------
void toto(c,i)
char *c;
int i;
{

} /* end of toto */
main()
{
        int i;
        int j;
        for (i=0;i<1000000;i++)
        {
                toto("%d\n",i+j+10);
        } /* end of for */
} /* end of main */
---------------- end of boucle.c -------------
compiling it with:
gcc -O -S -fstrength-reduce -fomit-frame-pointer boucle.c
I obtain:
----------------- boucle.s -------------------
#NO_APP
gcc_compiled.:
.text
        .even
.globl _toto
_toto:
        rts
LC0:
        .ascii "%d\12\0"
        .even
.globl _main
_main:
        moveml #0x3000,sp@-
        moveq #10,d2
        addl d0,d2
        movel d0,d3
        addl #1000009,d3
L6:
        movel d2,sp@-
        pea LC0
        jbsr _toto
        addqw #8,sp
        addql #1,d2
        cmpl d2,d3
        jge L6
        moveml sp@+,#0xc
        rts
-------------------- end of boucle.s --------------
which is quite good, but I would have expected:
-------------------- boucle.s.opti ----------------
#NO_APP
gcc_compiled.:
.text
LC0:
        .ascii "%d\12\0"
        .even
.globl _main
_main:
        moveml #0x3000,sp@-
        moveq #10,d2
        addl d0,d2
        movel d0,d3
        addl #1000009,d3
        movel d2,sp@-
        pea LC0
L5:
        movel d2,sp@(4)
        jbsr _toto
        addql #1,d2
        cmpl d2,d3
        jge L5
        addqw #8,sp
        moveml sp@+,#0xc
        rts
        .even
.globl _toto
_toto:
---------------------- end of boucle.s.opti-------------
which is quite better

Question: Is it possible to obtain such optimisations with gcc ?

-- 
Patrick SANCHEZ
INRIA-IRISA (Rennes) Campus de Beaulieu  F-35042 Rennes Cedex  FRANCE
PHONE : +33  99 36 20 00 ext 498             EMAIL : sanchez@irisa.fr
Technical Details
Message-ID: <1990Nov26.115923.10352@irisa.fr>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!corton!irisa!irisa.fr!sanchez

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,d36f3455078ec9a0,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1990-11-26 15:03:58 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!corton!irisa!irisa.fr!sanchez
From: sanchez@irisa.fr (Patrick Sanchez)
Newsgroups: gnu.gcc.help
Subject: gcc optimisation
Message-ID: <1990Nov26.115923.10352@irisa.fr>
Date: 26 Nov 90 11:59:23 GMT
Sender: news@irisa.fr
Reply-To: sanchez@irisa.fr (Patrick Sanchez)
Organization: Irisa, Rennes(FR)
Lines: 92
Posted: Mon Nov 26 12:59:23 1990