4.?BSD C fails to optimize a function's last expression--who has fix?
Arthur David Olson
ado at elsie.UUCP
Fri Sep 6 08:13:53 AEST 1985
Today's quiz: which of these two functions results in more
code after they've been run through the 4.?BSD optimizer:
one(i, j, k) two(i, j, k)
{ {
i = j * k; dummy();
dummy(); i = j * k;
} }
The answer: you get more code out of "two". Here are the results:
_one:.word L12 _two:.word L18
mull3 12(ap),8(ap),4(ap) calls $0,_dummy
calls $0,_dummy mull3 12(ap),8(ap),r0
ret movl r0,4(ap)
ret
And here's the explanation: in the second case, the optimizer sees that
something's been put in register zero and then there's a return, so
the optimizer figures that the thing put in register zero is a return value
(rather than a temporary value, as it is in this instance) and decides it
had best be left alone.
Has anybody out there figured out how to get better results in situations such
as this?
--
Bugs is a Warner Brothers trademark.
--
UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado at seismo.ARPA
DEC, VAX and Elsie are Digital Equipment and Borden trademarks
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list