Subject: Re: I want to rid ugly float load/stores used only for data movement
To: None <tech-toolchain@netbsd.org, port-macppc@netbsd.org,>
From: M L Riechers <mlr@rse.com>
List: tech-toolchain
Date: 02/25/2003 16:23:03
On Mon, 24 Feb 2003 11:24:30 +0000 Richard Earnshaw <rearnsha@arm.com>
kindly advised me:

> It ought to be possible to severely discourage use of fp registers for non 
> fp objects by arranging for MEMORY_MOVE_COST to return a large value when 
> given an FP register class and a non-FP mode.
> 
> This won't eliminate the use of such registers but it should cut it down 
> significantly if the compiler respects this correctly.
> 
> R.

Thanks for the tip, but it didn't work.

In /usr/local/src/usr/src/gnu/dist/toolchain/gcc/config/rs6000/rs6000.h I
changed:

#define MEMORY_MOVE_COST(MODE,CLASS,IN)	\
  ((GET_MODE_CLASS (MODE) == MODE_FLOAT	\
    && (rs6000_cpu == PROCESSOR_RIOS1 || rs6000_cpu == PROCESSOR_PPC601) \
 ? 3 : 2) \
   + 4)

to:

#define MEMORY_MOVE_COST(MODE,CLASS,IN)	\
  ((GET_MODE_CLASS (MODE) == MODE_FLOAT	\
/*    && (rs6000_cpu == PROCESSOR_RIOS1 || rs6000_cpu == PROCESSOR_PPC601) \
 ? 3 */ ? 12 : 2) \
   + 4)

(I at first by chance made an error editing this; the compile failed
on a syntax error at this error, so I'm sure that the compile used
this header file;   just to be sure, I put a deliberate error in 
/usr/local/src/usr/src/gnu/dist/gcc/config/rs6000/rs6000.h).

and then remade the tools from ./usr/src with:

nohup sh -c 'date; export DESTDIR=/usr/local/src/dest; export \
LOCALTIME=US/Eastern; ./build.sh -m macppc -t ; date' &

I found that /usr/bin/less has lots of gratuitous lfd/stfd pairs, so I
cd'd to ./usr/src/usr.bin/less and executed:

make clean; nohup make &

and got stuff like (abbreviated):

/usr/local/src/usr/src/tools/obj.macppc/tools.NetBSD-1.6-powerpc/bin/powerpc--netbsd-gcc
-O2  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
-Wno-uninitialized -Wno-strict-prototypes -Wno-missing-prototypes
-Werror  -I/usr/local/src/usr/src/usr.bin/less/less
-I/usr/local/src/usr/src/usr.bin/less/less/../lesskey
-DSYSDIR=\"/etc\" -nostdinc -isystem /usr/include  -c
/usr/local/src/usr/src/usr.bin/less/less/version.c

/usr/local/src/usr/src/tools/obj.macppc/tools.NetBSD-1.6-powerpc/bin/powerpc--netbsd-gcc
-o less -nostdlib  /usr/lib/crt0.o /usr/lib/crtbegin.o brac.o ch.o
charset.o cmdbuf.o command.o decode.o edit.o filename.o forwback.o
help.o ifile.o input.o jump.o line.o linenum.o lsystem.o main.o mark.o
optfunc.o option.o opttbl.o os.o output.o position.o prompt.o screen.o
search.o signal.o tags.o ttyin.o version.o -ltermcap -L/usr/lib  -lgcc
-lc -lgcc /usr/lib/crtend.o

and compared the new objdump's with old.  (I actually did this several
times.)  Exactly identical -- the lfd/stfd pairs were still there.

Repeating with:

#define MEMORY_MOVE_COST(MODE,CLASS,IN)	\
  ((GET_MODE_CLASS (MODE) == MODE_FLOAT	\
/*    && (rs6000_cpu == PROCESSOR_RIOS1 || rs6000_cpu == PROCESSOR_PPC601) \
 ? 3 */ ? 100 : 2) \
   + 4)

didn't help.

Apparently, gcc pays no attention to MEMORY_MOVE_COST under these
conditions.


Kind regards,

-Mike