From: Steve Wampler
Subject: Re: Parallelism
Date: 
Message-ID: <32ADCDA7.5958@gemini.edu>
Keith Bierman QED wrote:

> 
> FORTRAN (the standard) *never* required always executing the loop
> once. The '66 standard allowed it, by virtue of not defining what
> should happen (it was before my time, and I don't recall whether the
> old timers did it to accommodate some existing practice on some
> platform or whether it was a simple oversight).

The original FORTRAN (which, by virtue of being first, comprised
a standard) had 1-trip DO-loops (i.e. code in the loop was always
executed at least once).  This was, indeed, a feature - the old
IBM machines had an instruction that fit the execution of a 
DO-loop test and branch quite nicely *if* the test was done at
the end of the loop.  A 'standard' FORTRAN (one defined by a
consortium) came along quite a ways afterwards.  As far as I can
remember, it wasn't until FORTRAN IV that some compilers started
allowing 0-trip Do-loops, provided you remember to drop the
correct option card into the deck.

The reason for the 1-trip DO-loop was the same as the reason
for the three-way branch: there was a particularly efficient
way to implement them on the original target machine, so they
were put into the language.


-- 
Steve Wampler - ········@gemini.edu [Gemini 8m Telescopes Project (under
AURA)]
The Gods that smiled upon your birth are laughing now. -- fortune cookie
From: David Ecale
Subject: Re: Parallelism
Date: 
Message-ID: <58lj0m$p3t@walter.cray.com>
Steve Wampler wrote:
<> The original FORTRAN (which, by virtue of being first, comprised
<> a standard) had 1-trip DO-loops (i.e. code in the loop was always
<> executed at least once).  This was, indeed, a feature - the old
<> IBM machines had an instruction that fit the execution of a 
<> DO-loop test and branch quite nicely *if* the test was done at
<> the end of the loop.

Hmmm...  Well, I can't attest to Autocoder on the IBM 1401, but, if we are
talking about FORTRAN66, then I am going to point out that the instruction
in mind on IBM OS360/370 was explicitely designed to work DO loops.  It was
called Branch on indeX Low or Equal, BXLE.  It's compatriate was Branck on
indeX High, BXH.  I passed a job interview for EDS (I ended up not taking
the job) by being able to explain the instruction execution.  Here's how
BXLE works:

*	T&B here to bail before 1st pass (very effecient)
	LA	R1,START		* Starting Address of Array
	LA	R2,DISP			* Stride through the Array
	LA	R3,END-DISP		* Ending Address of Array
LOOP	=	*
	.
	.				* Pass through the array ...
	.
*	T&B here to bail after 1st pass (very in-effecient)
	BXLE	R1,R3,LOOP		* R1 gets R1 + R2
					* If new R1 =< R3 then branch to LOOP
					* Else fall through, we're done ...

Note that the BXLE & BXH were designed to be placed at the bottom of the
loop.  A test and branch sequence would need to be set up directly before
the LOOP tag to bail out on a no-pass option.  Once in this loop, you were
going for the long haul.  The (really bad BAL) code example above basicaly
defines a DO loop in FORTRAN. It is also used in a FOR loop in other
languages.

Note also that a test & branch inside the loop was a common way (in the bad
old days) for bailing out mid way through a DO loop.  Needless to say,
putting a test and branch dependancy in the loop caused the code to fail to
vectorize.  But, hey, this was the 60s, after all!

And, for the real affectionados, Test and Set, TS would set a trap door so
that a piece of code would only be used once!  The way I originally learned
to do this was (NOP = No Operation, OI = Or Immediate, & B = Branch):

TAG	NOP	SKIP			* This is a  "47 00 A(SKIP)"
	OI	X'F0',TAG+1		* This makes "47 F0 A(SKIP)"
					*    which is "B   SKIP" !!!

Yup, my first piece of self-modifying code, ever. !!!

<<God!  It's good to get that out of my system!  Can I go home now, Mr.
Watson?>>

-- 
David Ecale
·····@cray.com			Work = 612-683-3844 // 800-BUG-CRAY x33844
http://wwwsdiv.cray.com/~ecale	Beep = 612-637-0873