long vs. int vs. short guidelines (e - (nf)

jc at inmet.UUCP jc at inmet.UUCP
Thu Apr 19 21:20:13 AEST 1984


#R:burl:-43000:inmet:10300013:000:995
inmet!jc    Apr 18 14:20:00 1984


...int is the natural size suggested by the machine architecture, i.e., faster.

Not on the VAX it ain't.  I recently did a bunch of timing tests on an 11,
a VAX, and a 68000.  On the latter machines, replacing short with int caused
the times to increase, sometimes dramatically (50% or more).  Furthermore,
storing a boolean as a short was consistently slower than as a char, even
on the so-called 32-bit machines.

My suggestion (for what it's worth) is to use pseudo-types for all globals,
and for all params and locals that aren't registers.  Registers are usually
coerced to int or long anyway, so I don't bother with them.  Incidentally,
some of my tests (especially on a 4341 running Amdahl's UTS) ran faster if
I didn't use registers, but let the compiler do its own allocation.  One the
other hand, on the 11 and VAX, the version with registers was usually faster.
Maybe you should use a pseudo-type even for register variables.

                                ...jc!inmet
----------



More information about the Comp.unix.wizards mailing list