Put your code... (was Re: gotos

David Goodenough dg at lakart.UUCP
Mon May 2 23:55:47 AEST 1988


>From article <1988Apr27.164212.12535 at utzoo.uucp>, by henry at utzoo.uucp (Henry Spencer):
> One can avoid this to some degree in C by using case fallthrough.  Otherwise,
> I agree but would phrase it differently:  for "with today's larger memories"
> substitute "with sensible compilers".  It doesn't take much of an optimizer
> to notice that the instruction sequences preceding an unconditional control-
> flow merge are identical, and condense them into one by branching to the
> beginning of the sequence rather than the end.  Any peephole optimizer
> worthy of the name ought to be willing to do this.

Well said - in 1980 the Bell labs V6 Unix C compiler part 'c2' could be
made to print out what it had done, and one message was

42 Common code before branches

Exactly what Mr. Spencer is talking about. I'm tempted to add that a good
peephole optimizer should be added to some current compilers: it gets my
back up when our compiler generates code like

	movl	d0,d0

or

	movl	d1,d0
	movl	d1,d0

I've seen both of these!! No kidding! Or when it puts 'nop's into the
assembler source.
--
	dg at lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!adelie!cfisun!lakart!dg	+-+-+ |
						  	  +---+



More information about the Comp.lang.c mailing list