forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Computed GO TO triggers optimiser bug
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat May 02, 2015 6:15 pm    Post subject: Reply with quote

Without wishing to water down the INTENT=BUG_REPORT, but in the interests of INTENT=HISTORICAL_CURIOSITY, in the absence of the computed GOTO, and without logical IFs and suchlike, one might write:

Code:
      IF ((I-1)*(15-I)) 80,10,10
10    IF (I-2)  999, 999, 20
20    IF (I-4)  130, 150, 30
30    IF (I-6)  170, 190, 40
40    IF (I-8)  210, 230, 50
50    IF (I-10) 250, 270, 60
60    IF (I-12) 290, 310, 70
70    IF (I-14) 330, 350, 500
80    CONTINUE


Using the ICL Fortran compiler (for Fortran 66 under the George OS on 1900 and 2900 series computers) statement 0 meant 'next line', so this could be written with far fewer statement numbers:

Code:
      IF ((I-1)*(15-I)) 10,0,0
      IF (I-2)  999, 999, 0
      IF (I-4)  130, 150, 0
      IF (I-6)  170, 190, 0
      IF (I-8)  210, 230, 0
      IF (I-10) 250, 270, 0
      IF (I-12) 290, 310, 0
      IF (I-14) 330, 350, 500
10    CONTINUE


This whole shebang would have been on cards, so obviously no comments or blank lines ...

Of course, the IFs could have been interspersed with the code, but I've always preferred to have the route map in advance. Indeed, that rules out for me at least, elaborate IF ... THEN ... etc constructs. The first arithmetic IF provides the range check. If efficiency rather than clarity was the goal, the first statement (in standard, not ICL) might be better as:

Code:
       IF (I*(16-I)) 80,80,10


By clarity I mean that the statement does not contain the numerical values of the first and last admissible i value, nor the first inadmissible one.

Rather interestingly, one would perhaps change the order of the IF statements and their content to match the frequency with which various I values were likely to crop up to minimise the number of IF statements executed.

And why all this? I believe there is still a role for hand optimisation which (within the limitations of the tools you work with) does not have to lead to difficult to follow code. If I had the list of arithmetic IFs as above, my first step in 'improving' it would be to add a comment or ten explaining what it does, and leave well alone afterwards until I had several idle hours to spend on it.

But I wouldn't write it like that nowadays!

Eddie
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sat May 02, 2015 7:41 pm    Post subject: Reply with quote

The form IF (arith_expr) nnn, 0, 0 (with '0' standing for 'next line') is new to me. Perhaps, by several decades, this convention predates but closely resembles the instruction-pointer-relative addressing used in the x86 and other processors.

With that special meaning assigned to the label 0, should a card fall out of the hopper while the deck was being read in, you would get no "missing label nnn" error from the compiler at all, and run-time behavior could be mysterious. I can see that in this situation having card sequence numbers would be vital.


Last edited by mecej4 on Mon Jun 06, 2016 7:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sun May 03, 2015 11:46 am    Post subject: Reply with quote

No doubt early Fortran statement types were aligned to processor instructions as one step beyond assembly languages, as distinct from (say) Algol which provides tools to describe algorithms in a standard way. The arithmetic IF goes right back to the beginning.

ICL's zero statement number was an innovative way to reduce the plethora of statement numbers, but it was an extension that no one else adopted. Like all extensions, once you used it on a large scale it impeded transferring the source code to another manufacturer's computers.

The nature of cards was that dropping just one was rather improbable. Drop a box of 2000 at the top of a 5-storey staircase (without risers) - done that. Shred one? Sure. Throw 500 into the air with a high-speed reader jam - that too. The only time I've lost just one line of code was when it was highlighted (but off screen) in a text editor and I pressed another key. It's over 30 years since I used cards, and over 20 since I threw them out.

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jun 06, 2016 4:10 pm    Post subject: Reply with quote

The original failure has now been fixed for the next release.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group