Path: utzoo!mnetor!uunet!husc6!think!ames!lll-tis!lll-lcc!pyramid!prls!mips!earl From: earl@mips.UUCP (Earl Killian) Newsgroups: comp.arch Subject: Re: taken -vs- untaken branches, Fortran FREQUENCY declaration Message-ID: <1365@gumby.UUCP> Date: 20 Jan 88 06:40:24 GMT References: <496@cresswell.quintus.UUCP> <638@l.cc.purdue.edu> <836@ima.ISC.COM> <2652@mmintl.UUCP> Lines: 36 In article <2652@mmintl.UUCP>, franka@mmintl.UUCP (Frank Adams) writes: > I will note in passing that the assumption that continuing a loop is more > likely than terminating it is often wrong. Loops of the form: > > while (error is present) { > try to fix it; > } > > are not all that uncommon. True, they are common, but precisely because such things execute 0 or 1 times means they don't weight branch statistics as heavily as the "real" loop that executes 10 times. Also, while (t) { body } is usually compiled as if (t) { do { body } while (t); } by a good compiler. Thus the backward branch in this loop is never executed in your case, and so doesn't affect the statistics of backward branches. When I last measured backward conditional branches on 13 programs, I found an average of 85% are taken. The data on forward branches was 52% (i.e. 50-50). That's the average behavior; individual programs tended to vary a whole lot on the frequency of forward branches. One final statistic: backward branches were only 28% of the total on average. Another way of thinking about this is that the average loop contains 2.6 forward branches (e.g. executed if statements).