Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!dalcs!thompson From: thompson@dalcs.UUCP (Michael A. Thompson) Newsgroups: comp.unix.questions Subject: Re: Wierd Compilers Message-ID: <2678@dalcs.UUCP> Date: Tue, 3-Nov-87 12:29:01 EST Article-I.D.: dalcs.2678 Posted: Tue Nov 3 12:29:01 1987 Date-Received: Fri, 6-Nov-87 22:36:41 EST References: <367@white.gcm> Reply-To: thompson@dalcs.UUCP (Michael A. Thompson) Organization: Math, Stats & CS, Dalhousie University, Halifax, NS, Canada Lines: 48 Keywords: Sun In article <367@white.gcm> dc@gcm (Dave Caswell) writes: > >Does anyone have a guess why program one runs in half the time of program two? >BTW this is a SUN 3. The same occures on our VAX 11/785 running BSD4.3: Program 1 0.7u 0.0s 0:00 81% 1+5k 0+0io 1pf+0w Program 1 w/-O 0.7u 0.0s 0:00 97% 1+5k 0+1io 1pf+0w Program 2 1.1u 0.0s 0:01 97% 1+5k 0+1io 1pf+0w Program 2 w/-O 0.9u 0.0s 0:01 71% 1+5k 0+1io 1pf+0w Here is the assembler output from our C compiler: Program 1: Program 2: . . . . . . L16: L16: decl -4(fp) movl -4(fp),r0 jeql L17 decl -4(fp) jbr L16 tstl r0 L17: jeql L17 . jbr L16 . L17: . . . . Program 1 w/-O: Program 2 w/-O: . . . . . . L16:decl -4(fp) L16:movl -4(fp),r0 jneq L16 decl -4(fp) . tstl r0 . jneq L16 . . . . Without trying to go into why the compiler constructs it's loops this way, it is pretty obvious that program 2 is taking longer because it has more instructions to execute each time through the loop. -- Michael A. Thompson, Dept. Math, Stats, & C.S., Dalhousie U., Halifax, N.S. thompson@dalcs.uucp From Bitnet or Uucp thompson@cs.dal.cdn From Bitnet or Cdn thompson%dalcs.uucp@uunet.uu.net From Arpa