Should optimizing compilers automatically assign registers?

Michael van Elst p554mve at mpirbn.UUCP
Mon May 7 07:02:05 AEST 1990


In article <512 at hhb.UUCP> istvan at hhb.UUCP (Istvan Mohos) writes:
>Prog1 and prog2 are identical except that prog1 requests the
>assignment of the auto variable p to a hardware register.
>I mistakenly assumed that by using the -O flag, the compiler
>would optimize prog2, and generate identical objects from
>prog1 and prog2.  Of the systems I tried this on, the Pyramid90X,
>the Sparcstation1, and a SystemV 6300+ PC, proved this to be true.
>A VAX Ultrix and a Sun3 proved me wrong.  Here are some execution

I've simply checked this by looking at the cc -S output.

The Sun C compiler does not allocate registers when run with
optimizer level 1 but it does so with level 2. The -O option
just invokes a peephole optimizer.

The difference between Sparc and Sun-3 systems is that the Sparc
compiler will run -O2 if invoked with just -O while the Sun-3
defaults to -O1. Under SunOS 4.1, both systems will use -O2.

-- 
Michael van Elst
UUCP:     universe!local-cluster!milky-way!sol!earth!uunet!unido!mpirbn!p554mve
Internet: p554mve at mpirbn.mpifr-bonn.mpg.de
                                "A potential Snark may lurk in every tree."



More information about the Comp.unix.wizards mailing list