This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PPC optimisation miss.


/* Ok..please forget the sense of this weird program.
 * Simular blocks occur in some automatic generated
 * code.
 * compiled with -O2
 */

register unsigned long*	rega __asm("r13");
register unsigned long	regb __asm("r14");

void	test(void)
{
unsigned long data;
  rega	=(unsigned long*) ((unsigned long) rega + 2);
  data	=	regb+*((short*)rega);
  rega	=(unsigned long*) ((unsigned long) rega + 2);
  rega	=(unsigned long*) data;
}

/* gives the following code

        .file   "test10.c"

 # rs6000/powerpc options: -msdata=data -G 8
# GNU C version egcs-2.91.57 19980901 (egcs-1.1 release) (ppc-amigaos) compiled by GNU C version egcs-2.91.57 19980901 (egcs-1.1 release).
 # options passed:  -O2 -fverbose-asm -fstrict-aliasing
 # options enabled:  -fdefer-pop -fomit-frame-pointer -fcse-follow-jumps
 # -fcse-skip-blocks -fexpensive-optimizations -fthread-jumps
 # -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse -finline
 # -fkeep-static-consts -fcaller-saves -fpcc-struct-return -fgcse
 # -frerun-cse-after-loop -frerun-loop-opt -fschedule-insns
 # -fschedule-insns2 -fsched-interblock -fsched-spec -fsjlj-exceptions
 # -fcommon -fverbose-asm -fgnu-linker -fregmove -foptimize-register-move
 # -fargument-alias -fstrict-aliasing -mpowerpc -mnew-mnemonics -mcall-sysv
 # -msdata=data

gcc2_compiled.:
        .section        ".text"
        .align 2
        .globl test
        .type    test,@function
test:
        addi 13,13,2
        lha 0,0(13)
        addi 13,13,2
        add 13,14,0
        blr
..Lfe1:
        .size    test,.Lfe1-test
        .ident  "GCC: (GNU) egcs-2.91.57 19980901 (egcs-1.1 release)"


If you look a bit closer the code should be
        lha 0,2(13)
        add 13,14,0
        blr

As it looks the compiler doesn`t notice register rega being trashed(would make
1st+2nd addi 13,13,2 worthless) and it makes no use of the offset to optimize
away the first addi 13,13,2
*/

Regards

---
Ralph Schmidt,laire@popmail.owl.de(private),NextMail welcome


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]