Article View: gnu.gcc.bug
Article #6363GCC patch #4
From: buc
Date: Tue, 05 Dec 1995 00:00
Date: Tue, 05 Dec 1995 00:00
217 lines
8532 bytes
8532 bytes
*m68k.h: no force mem for mc680[346]0
Dmitry K. Butskoy (buc@stu.spb.su)
GCC: 2.7.0
CPU: m68k
(Our configuration:
CPU: mc68030/mc68882
Computer: BESTA (similar to `mot3300 delta')
System: SVR3.1 (similar to sysV68)
asm: SGS System V/68 R2V1 syntax )
We had some experiments to see the influence of different
`-f' options on the resulting assembler code and found that
`-fforce-mem' option doesn`t have a positive effect if the processor
has on-chip data cashe. ( mc680[012]0 have no such cashe, but
mc680[346]0 have ).
test ( sysV library variant of strchr() )
****file foo.c****
char *strchr( char *a , char b ) {
do if(*a == b) goto ok;
while(*a++) ;
a = 0;
ok: return a;
}
******************
`gcc -S -O2 -fforce-mem foo.c'
result #1
file "foo.c"
text
even
global strchr
strchr:
mov.l 4(%sp),%a0
mov.b 11(%sp),%d1
L%L2:
mov.b (%a0),%d0
cmp.b %d1,%d0
beq.w L%L6
add.w &1,%a0
tst.b %d0
bne.w L%L2
sub.l %a0,%a0
L%L6:
rts
nop
`gcc -S -O2 -fno-force-mem foo.c'
result #2
file "foo.c"
text
even
global strchr
strchr:
mov.l 4(%sp),%a0
mov.b 11(%sp),%d0
L%L2:
cmp.b %d0,(%a0)
beq.w L%L6
tst.b (%a0)+
bne.w L%L2
sub.l %a0,%a0
L%L6:
rts
nop
Within the loop ` L%l2: . . . . bne.w L%L2 ' the result #1
has 2 insns more than the result #2 . This is caused by the desire
to exclude extra memory references to one and the same address
(`force-mem'). This may be efficient for chips having no data cashe.
But in case there is such data cashe, the result #2 shows more
efficient, because there will not be any actual references to external
memory. Under these circumstances:
-the code length appears to be less,
-the code requires a bit less times for its execution,
-no extra regs required.
To make a more efficient code one should consider these processor
features somehow. The most evident way to do it is: to give all possible
m68k CPU types in TARGET_SWITCHES macro definition (m68k.h) and
to use macro CC1_SPEC to set `-fforce-mem' on or off. (`-fforce-mem'
normally is a part of `-O2' option).
Hear are the patches needed:
`diff -p -c4' for config/m68k/m68k.h
*** m68k.h Thu Jun 15 22:13:04 1995
--- m68kNEW.h Fri Dec 1 19:23:26 1995
*************** extern int target_flags;
*** 103,136 ****
{ { "68020", -01400}, \
{ "c68020", -01400}, \
{ "68020", 5}, \
{ "c68020", 5}, \
! { "68881", 2}, \
! { "bitfield", 4}, \
{ "68000", -01405}, \
{ "c68000", -01405}, \
{ "soft-float", -01102}, \
{ "nobitfield", -4}, \
{ "rtd", 8}, \
{ "nortd", -8}, \
{ "short", 040}, \
{ "noshort", -040}, \
{ "fpa", 0100}, \
{ "nofpa", -0100}, \
{ "sky", 0200}, \
{ "nosky", -0200}, \
- { "68020-40", 0407}, \
- { "68030", -01400}, \
- { "68030", 5}, \
- { "68040", 01007}, \
{ "68851", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "no-68851", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "68302", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "no-68302", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "68332", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "no-68332", 0}, /* Affects *_SPEC and/or GAS. */ \
SUBTARGET_SWITCHES \
{ "", TARGET_DEFAULT}}
/* TARGET_DEFAULT is defined in sun*.h and isi.h, etc. */
/* This is meant to be redefined in the host dependent files */
#define SUBTARGET_SWITCHES
--- 103,147 ----
{ { "68020", -01400}, \
{ "c68020", -01400}, \
{ "68020", 5}, \
{ "c68020", 5}, \
! { "68030", -01400}, \
! { "c68030", -01400}, \
! { "68030", 5}, \
! { "c68030", 5}, \
! { "68040", -0400}, \
! { "c68040", -0400}, \
! { "68040", 01007}, \
! { "c68040", 01007}, \
! { "68020-40", -01000}, \
! { "68020-40", 0407}, \
{ "68000", -01405}, \
{ "c68000", -01405}, \
+ { "68010", -01405}, \
+ { "c68010", -01405}, \
+ { "68881", 2}, \
{ "soft-float", -01102}, \
+ { "bitfield", 4}, \
{ "nobitfield", -4}, \
{ "rtd", 8}, \
{ "nortd", -8}, \
+ { "regparm", 020}, \
+ { "noregparm", -020}, \
{ "short", 040}, \
{ "noshort", -040}, \
{ "fpa", 0100}, \
{ "nofpa", -0100}, \
{ "sky", 0200}, \
{ "nosky", -0200}, \
{ "68851", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "no-68851", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "68302", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "no-68302", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "68332", 0}, /* Affects *_SPEC and/or GAS. */ \
{ "no-68332", 0}, /* Affects *_SPEC and/or GAS. */ \
SUBTARGET_SWITCHES \
{ "", TARGET_DEFAULT}}
+
/* TARGET_DEFAULT is defined in sun*.h and isi.h, etc. */
/* This is meant to be redefined in the host dependent files */
#define SUBTARGET_SWITCHES
*************** extern int target_flags;
*** 156,163 ****
--- 167,179 ----
/* This is meant to be redefined in the host dependent files */
#define SUBTARGET_OVERRIDE_OPTIONS
+ #ifndef CC1_SPEC
+ #define CC1_SPEC "%{O2:%{!m68000:%{!m68010:%{!m68020:-fno-force-mem}}}}"
+ #endif
+
+
/* target machine storage layout */
/* Define for XFmode extended real floating point support.
This will automatically cause REAL_ARITHMETIC to be defined. */
*Notes*
Macro CC1_SPEC is currently defined in config/m68k/crds.h,
config/m68k-none.h, config/m68k/sun2.h and config/m68k/sun3.h .
To install this patch above definitions should be followed with
changes mentioned. I can send necessary patches later.
By default (no `-m' switches) I define `-fno-force-mem' ,
considering that mc680[346]0 (have data cashe) are now more frequent.
Dmitry K. Butskoy,
Saint-Petersburg State Technical University,
St. Petersburg, Russia.
<buc@stu.spb.su>
Technical Details
Message-ID:
<AAY87nmin3@stu.spb.su>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,db72beb8110eeb87,start X-Google-Attributes: gid113d02,public From: buc@stu.spb.SU Subject: GCC patch #4 Date: 1995/12/05 Message-ID: <AAY87nmin3@stu.spb.su> X-Deja-AN: 120945675 distribution: gnu sender: daemon@cis.ohio-state.edu organization: State Technical University of St. Petersburg newsgroups: gnu.gcc.bug