defeating the optimiser (was Ambiguous C?)

T. William Wells bill at twwells.uucp
Mon May 1 00:16:12 AEST 1989


In article <17195 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
:                                                           Sun provide
: a program called `inline' that uses this approach, and (I presume)
: also tries to avoid unnecessary pushes and pops, changing something
: like
:
:               pea     a4@(12)
:               jsr     _readlong
:               movl    #10,d1
:               btst    d1,d0   | btst cannot test bit 10 directly
:
: plus
:
:       _readlong:
:               movl    sp@(4),a0
:               movl    a0@,d0
:               rts
:
: into
:
:               lea     a4@(12),a0
:               movl    a0@,d0
:               movl    #10,d1
:               btst    d1,d0
:
: or even (if smart enough) merging the lea+movl into one movl.

If this is what I think it is, I was reading about this (it's in the
floating point manual, an obvious place, right?) some time ago. What
is described there are .il files, which you use by naming them on
your cc command.

The .il files contain assembly code which the compiler inserts in
line for you. The manual gives some instructions on how to write the
functions in such a way that the optimizer will remove the function
call overhead.

It's a neat trick if you need inline assembly. And avoids nonportables
like the asm keyword. (I think I got this right. It's been a while.)

---
Bill                            { uunet | novavax } !twwells!bill



More information about the Comp.lang.c mailing list