Article View: gnu.gcc.bug
Article #2745pessimized structure filling code on gcc for m68k
From: Mike Albaugh
Date: Wed, 07 Jun 1989 20:50
Date: Wed, 07 Jun 1989 20:50
192 lines
4953 bytes
4953 bytes
gcc for Motorola 68000 produces byzantine (but not strictly speaking
wrong) code for assignments to the fields of a structure whose total length
is <= 8 bytes.
Using the suppiled m68k.md, and a home-made tm.h file which defines
MOTOROLA and SGS, then includes tm-m68k.h and fixes up some assembler stuff.
The host machine is a vms vax, so an un-modified xm-vms (aka config-vms)
was used. This was run on both Micro-vax II and III, although I doubt the
host machine has much to do with it. TARGET_DEFAULT was #defined 0, so
this was to produce code for a naked 68000.
Both 1.22 and 1.34 exhibit this behavior, as shown below. Increasing the
size of the structure above 8 bytes results in sane code. By this I mean
the "normal" use of move.b instructions rather than shifting and logical
ops between real regs and stack slots. FYI, note that while 1.34 was just
a touch "smarter" about the byte assignment to "row", it seems to have
become less intelligent about register life. Note the reload of the constant
16, and the fact that it used one more register, although it had a dead one
(d1 or d2, depending on viewpoint) available.
I seldom use short structures, but thought you might be interested.
Mike
| Mike Albaugh (albaugh@dms.UUCP || {...decwrl!turtlevax!}weitek!dms!albaugh)
| Atari Games Corp (Arcade Games, no relation to the makers of the ST)
| 675 Sycamore Dr. Milpitas, CA 95035 voice: (408)434-1709
| The opinions expressed are my own (Boy, are they ever)
The file (pre-processed):
----------------------------
# 1 "stru_tst.c"
typedef struct mt2
{
unsigned char xxx;
unsigned char yyy;
unsigned char *text;
char chain;
} MT2;
extern char col,row;
extern void write_m();
static pmess(x,y,string)
char x,y,*string;
{
MT2 tbuff;
tbuff.xxx = x;
row = tbuff.yyy = y;
for (col = 0 ; string[col] ; col++);
col += x;
tbuff.text = string;
tbuff.chain = 0;
write_m(&tbuff,0);
}
--------------------
output from cc1 stru_tst.cpp -opt -o stru_tst.s_22
--------------------
pmess
time in parse: 0.240000
time in integration: 0.000000
time in jump: 0.010000
time in cse: 0.080000
time in loop: 0.000000
time in flow: 0.060000
time in combine: 0.020000
time in local-alloc: 0.040000
time in global-alloc: 0.040000
time in final: 0.070000
time in varconst: 0.000000
time in symout: 0.000000
time in dump: 0.000000
--------------------------
file stru_tst.s_22
--------------------------
SECTION 9
DS.W 0
pmess:
link a6,#-8
movem.l d3/d2,-(sp)
move.b 11(a6),d2
move.l 16(a6),a0
clr.l d0
move.b d2,d0
moveq.l #24,d3
lsl.l d3,d0
move.l #16777215,d1
and.l -8(a6),d1
move.l d1,-8(a6)
or.l d0,d1
move.l d1,-8(a6)
clr.l d0
move.b 15(a6),d0
moveq.l #16,d3
lsl.l d3,d0
and.l #-16711681,d1
move.l d1,-8(a6)
or.l d0,d1
move.l d1,-8(a6)
lsr.l d3,d1
and.b #255,d1
move.b d1,row
clr.b col
bra L2
L4:
addq.b #1,col
L2:
move.b col,d0
ext.w d0
tst.b 0(a0,d0.w)
bne L4
add.b d2,col
move.l a0,-8(a6)
and.w #255,-2(a6)
clr.l -(sp)
pea -8(a6)
jsr write_m
movem.l -16(a6),d2/d3
unlk a6
rts
---------------------------------
using 1.34 as cc1, output from cc1 stru_tst.cpp -opt -o stru_tst.s_34
--------------------------------
pmess
stru_tst.c:20: warning: assignment between incompatible pointer types
time in parse: 0.290000
time in integration: 0.000000
time in jump: 0.000000
time in cse: 0.090000
time in loop: 0.020000
time in flow: 0.020000
time in combine: 0.040000
time in local-alloc: 0.050000
time in global-alloc: 0.080000
time in final: 0.100000
time in varconst: 0.000000
time in symout: 0.000000
time in dump: 0.000000
----------------------------
the file stru_tst.s_34
----------------------------
gcc_compiled.:
SECTION 9
DS.W 0
pmess:
link a6,#-8
movem.l d4/d3/d2,-(sp)
move.b 11(a6),d3
move.b 15(a6),d1
move.l 16(a6),a0
clr.l d2
move.b d3,d2
moveq.l #24,d4
lsl.l d4,d2
move.l -8(a6),d0
and.l #16777215,d0
move.l d0,-8(a6)
or.l d2,d0
move.l d0,-8(a6)
clr.l d2
move.b d1,d2
moveq.l #16,d4
lsl.l d4,d2
and.l #-16711681,d0
move.l d0,-8(a6)
or.l d2,d0
move.l d0,-8(a6)
moveq.l #16,d4
lsr.l d4,d0
move.b d0,row
clr.b col
bra L2
L4:
addq.b #1,col
L2:
move.b col,d0
ext.w d0
tst.b 0(a0,d0.w)
bne L4
add.b d3,col
move.l a0,-8(a6)
and.w #255,-2(a6)
clr.l -(sp)
pea -8(a6)
jsr write_m
movem.l -20(a6),d2/d3/d4
unlk a6
rts
Technical Details
Message-ID:
<8906090259.AA00258@apple.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!EDDIE.MIT.EDU!think!ames!claris!apple!dms!albaughShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!EDDIE.MIT.EDU!think!ames!claris!apple!dms!albaugh From: think!ames!claris!apple!dms!albaugh@EDDIE.MIT.EDU (Mike Albaugh) Newsgroups: gnu.gcc.bug Subject: pessimized structure filling code on gcc for m68k Message-ID: <8906090259.AA00258@apple.com> Date: 7 Jun 89 20:50:34 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 192