Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site ucbvax.UUCP
Path: utzoo!decvax!harpo!floyd!vax135!cornell!uw-beaver!tektronix!ucbcad!ucbvax!mckusick
From: mckusick@ucbvax.UUCP
Newsgroups: net.unix-wizards,net.lang.c
Subject: Re: Some questions about the C -Optimiser
Message-ID: <232@ucbvax.UUCP>
Date: Tue, 7-Jun-83 16:27:02 EDT
Article-I.D.: ucbvax.232
Posted: Tue Jun  7 16:27:02 1983
Date-Received: Sat, 11-Jun-83 17:35:58 EDT
References: <2083@edai.UUCP>
Organization: U. C. Berkeley Computer Science
Lines: 33

The reason that the optimizer frequently "misses" oportunities
to get rid of

	someopt	src,r0
	movl	r0,dst

is because r0 is used as the return value register. If all of
these were uniformly replaced by
	
	someopt	src,dst

then statements such as

	return (a = b + 1);

that generate code as

	addl3	$1,_b,r0
	movl	r0,_a

would get optimized to

	addl3	$1,_b,_a

and would never set r0, thus returning garbage. The optimizer
takes a very pessimistic view and never optimizes away assignments
to r0 if the assignment is at the end of a basic block. The appropriate
fix would be to have the C compiler avoid using r0 as a temporary
unless it either forced to, or meant to set the return value.

	Kirk McKusick
	ucbvax!mckusick
	mckusick@berkeley