Can C default to float? Are there float regs?

Ken Turkowski ken at turtlevax.UUCP
Sat Sep 14 03:11:52 AEST 1985


In article <175 at mit-bug.UUCP> dove at mit-bugs-bunny.UUCP (Web dove) writes:
>Many people in our group find it frustrating that C converts floating
>arithmetic to double.  Converting float variables to double, doing the
>calculation and converting back to float is usually so costly that it
>is faster to do it in double.  Unfortunately, this wastes space.
>Also, our machines (vax 750/4.2bsd) would be faster if the
>computations were done in straight float.  Many people resort to
>fortran/assembler to accomplish this, but it is unfortunate to need to use
>two languages.
>
>I realize that this violates the standard for C, but has anyone ever
>changed the compiler to accomplish this?

I've heard of some implementations that do this.  They have implemented
two separate compilers, which one can switch between with a flag:  one
for the "standard interpretation" of the C specification, and one that
accommodates "float" as a bonafide type with a complete set of
operations on them.

The 16-bit machines allowed for two types of fixed point arithmetic:
short (int) and long.  There is no reason why this could not also be
implemented for floating-point numbers.

>On a related note, it appears that register declarations for float variables 
>have no effect on our compiler (they don't cause the variables to be stored
>in registers).  It has been hypothesized that those who write the compiler
>don't feel that making "register float" do something is worth the effort.
>
>Is there anyone who has made "register float" work?  Is it impossible?

Similarly this is not impossible.  I don't believe that the C spec
precludes this.  It's just that many machines do not have
flaoting-point registers.

On machines such as the 68000 that have separate address and data
register sets, the C compiler doesn't normally distinguish between the
two when allocating them; special enhancements need to be made to the
compiler in order for the allocation to be done appropriately.  A
similar enhancement need to be done for floating-point registers.

-- 
Ken Turkowski @ CADLINC, Menlo Park, CA
UUCP: {amd,decwrl,hplabs,seismo,spar}!turtlevax!ken
ARPA: turtlevax!ken at DECWRL.ARPA



More information about the Comp.lang.c mailing list