Subject: Re: CPU instruction set optimization
To: David Brownlee <abs@anim.dreamworks.com>
From: Jeremy Cooper <jeremy@broder.com>
List: port-sun3
Date: 05/05/1998 17:07:40
On Tue, 5 May 1998, David Brownlee wrote:

> 	I could be missing something here, but is the sun3x kernel
> 	compiled with -m68030? I see the .s files are assembled with
> 	-m68030, but I do not see it in the CFLAGS?
> 
> 	The 680{2,3,4,6}0 issue is pretty much independant of which 68k
> 	based arch is being used - assuming the userland is completely
> 	sharable. (a sun3x and 68030 based mac would be able to run the
> 	same -m68030 compiled userland).
> 

Your first paragraph is correct.  The C code in the sun3x kernel is not
compiled with the -m68030 flag.  However, the parts of the kernel that can
and do benefit from 68030 specific instructions are written in assembler.

It is also true that those Macintosh machines that have 68030 CPUs would
still be binary compatible with sun3x machines if we decided to divide the
architectures among specific CPU lines.  But these binary sets would no
longer be useable on the vast majority of 68020 machines (sun3, other
Macintosh, hp300's).  This is a bummer because we currently have a grand
unified m68k architecture and we worked hard to achieve it.

The benefits of having a unified m68k architecture far outweigh any
benefit of optimization for specific CPUs for two reasons.  The first
reason is due to the number of m68k architectures we support:

 * Quick release time.  It takes just one build process to make 98% of the
   binaries in the amiga, atari, hp300, mac68k, sun3, sun3x, vme68k, and
   x68k ports.  (The other 2% are those binaries such as ``edlabel'' and
   boot blocks which are specific to each machine.)

 * Much smaller releases.  It takes up a lot less FTP and CDROM space if
   each of these ports shares a common binary set.

The second reason is due to the fact that there may be no benefit
whatsoever for CPU ``optimization''.  As someone just posted, gcc bothers
to differentiate instructions when compiling for 68030 and higher
processors only in some floating point cases.  There are very few programs
in the distribution which use floating point operations.  Gcc 2.8 and egcs
_may_ change this, but I doubt it will be that drastic.

I do recognize that many of us who run m68k machines will go to great
lengths to optimize the OS, even if the benefit is only psychological =).
In light of that desire I think it would be a good idea to document how to
compile your own distribution with the -m680x0 flags, be it comments in
/etc/mk.conf or in a badly needed README in the top-level directory of the
source tree. 

-J