🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Karl Fox Thu, 22 Sep 1988 22:26
gcc 1.28 optimization problem on m68k
#1693
Author: Karl Fox
Date: Thu, 22 Sep 1988 22:26
54 lines
1908 bytes
The following program is improperly optimized by gcc-1.28, using
config-m68k.h, m68k.md, output-m68k.h and our own test tm.h that
includes tm-m68k.h:

    % cat x.c
    int a = 0xE4;

    main()
        {
        register int b = a;

        printf("0x%X %d\n", b, (b & 0xF) + ((b >> 4) & 0xF));
        }

With -O, it prints "0xE4 2".  Without -O, it prints "0xE4 18", the
correct result.  Looking at the assembler shows that it assumed that
((b & 0xF) + ((b >> 4) & 0xF)) == (((b >> 4) + b) & 0xF):

    % gcc -v -O -S x.c
    gcc version 1.28
     /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dmasscomp -Dmc500 -Dunix -Dm68k -D_ATT -D__OPTIMIZE__ x.c /tmp/cca12047.cpp
    GNU CPP version 1.28
     /usr/local/lib/gcc-cc1 /tmp/cca12047.cpp -quiet -dumpbase x.c -O -version -o x.s
    GNU C version 1.28 (68k, MIT syntax) compiled by GNU C version 1.28.
    % cat x.s
    #NO_APP
    .globl _a
    .data
            .even
    _a:
            .long 228
    .text
    LC0:
            .ascii "0x%X %d\12\0"
            .even
    .globl _main
    _main:
            link a6,#0
            move.l d2,sp@-
            move.l _a,d0
            move.l d0,d1
            asr.l #4,d1
            add.l d0,d1
            moveq #15,d2
            and.l d2,d1
            move.l d1,sp@-
            move.l d0,sp@-
            pea LC0
            jbsr _printf
            move.l a6@(-4),d2
            unlk a6
            rts
-- 
Karl Fox, Morning Star Technologies ...!{att,osu-cis,pyramid}!mstar!karl
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads