[net.unix-wizards] Some questions about the C -Optimise

emrath@uiucdcs.UUCP (06/16/83)

#R:edai:-208300:uiucdcs:13700036:000:829
uiucdcs!emrath    Jun 16 02:40:00 1983

I have a thought about the second optimzation question, in the case
of the instruction    t = s & 0xffffff;  /* s and t are int's */

I have noticed that the optimzer does a fair job at reducing the size
of the code generated. It seems to strive for this, possibly under the
assumption that shorter code might be expected to execute faster
(in general, this seems like a good rule of thumb).

In this case, the optimzer generates:
	extzv	$position,$size,source,destination
rather than:
	bicl3	$mask,source,destination
The mask requires 5 bytes of code (in general), while the position and size
are small integer constants and only require 2 bytes.

Maybe this was the reason that extzv was used instead of the bicl3, that
the implementor(s) didn't have time to run speed tests on every possible
optimization.  I'm just guessing.

ucbmonet.arnold@ucbcad.UUCP (06/29/83)

#R:edai:-208300:ucbmonet:23900001:000:370
ucbmonet!arnold    Jun 28 18:19:00 1983

The C compiler has historically optimized for space first and speed
second.  I believe this came about when proto-UNIX was being re-written
in C from assembler to minimize the increase in size.  But all optimizers
must choose at times between space and speed optimizations, and whichever
you choose, situations will be found in which this is a loss for the other.
		Ken