/lib/c2 optimizes calls instructions
Arthur David Olson
ado at elsie.UUCP
Fri Aug 23 01:22:21 AEST 1985
> >Index: /lib/c2, BRL-Unix release 3, likely appears in other 4.?BSD.
> >Problem: Calls instructions have a format "calls <const-#-of-args>,<addr>".
> > The <const-#-of-args> argument will sometimes be "optimized" into
> > a register reference. This isn't necessary. . .
>
> It saves a little teensy bit of time. . .
Hmmm. . .let's check this out with the following program on a VAX 11/750
(4.1bsd, cp_urev = 94, cp_hrev = 72):
main(argc, argv)
int argc;
char * argv[];
{
register int i;
i = atoi(argv[1]);
do {
one();
two();
} while (--i > 0);
}
dummy1() { dummy1(); dummy1(); dummy1(); dummy1(); dummy1(); }
one()
{
register int i, j;
i = 1000;
do {
j = 0;
subr();
} while (--i > 0);
}
dummy2() { dummy2(); dummy2(); dummy2(); dummy2(); dummy2(); }
two()
{
register int i, j;
i = 1000;
do {
subr();
j = 0;
} while (--i > 0);
}
dummy3() { dummy3(); dummy3(); dummy3(); dummy3(); dummy3(); }
subr() {}
If I name the above "try.c" and
cc -c -O try.c ; cc -p -O try.o ; a.out 10000 ; prof
I get this output:
%time cumsecs #call ms/call name
60.8 325.10 _subr
20.2 433.28 _one
18.9 534.22 _two
0.1 534.73 _main
which says that the function "one", with its
L33:clrl r10
calls r10,_subr
sobgtr r11,L33
takes more time than function "two", with its
L46:calls $0,_subr
clrl r10
sobgtr r11,L46
loop.
Comments?
--
Bugs is a Warner Brothers trademark.
UNIX is an AT&T Bell Laboratories trademark.
BRL is a Bethesda Research Laboratories 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