A respectful correction, Brian.

On 4/20/2012 4:50 AM, Brian Leach wrote:
it's all the same to the compiler.
-----Original Message-----
    BEGIN CASE
       CASE A = "TEST"; GOSUB DO.SOMETHING
       CASE 1; GOSUB DO.SOMETHING.ELSE
    END CASE
versus this
    IF A = "TEST" THEN GOSUB DO.SOMETHING ELSE GOSUB DO.SOMETHING.ELSE
-----

Since we seem to be finding every nit in the bottom of this empty barrel, here's one more.
There are 2 compiler difference as shown by VLIST (UV10.2):

00001: BEGIN CASE

00002:    CASE A = "TEST"; GOSUB DO.SOMETHING
00002 00000 : 06E eq             A "TEST"  => $R0
00002 00008 : 2DE testfw         $R0 00020:
00002 00010 : 0A4 gosub          00060:


00003:    CASE 1; GOSUB DO.SOMETHING.ELSE
00003 00018 : 0C2 jump           00038:
00003 00020 : 2DE testfw 1 00038: <-------------- Extra worthless test
00003 00028 : 0A4 gosub          00062:

00004: END CASE
00004 00030 : 0C2 jump 00038: <-------------- Extra worthless jump (to next line)
                                                                          
(Source lineup is goofy.  This jump is really part
of source line 3. RAID is confusing, too.
                                                                           A 
discussion for a different thread.)

00005: IF A = "TEST" THEN GOSUB DO.SOMETHING ELSE GOSUB DO.SOMETHING.ELSE
00005 00038 : 06E eq             A "TEST"  => $R0
00005 00040 : 2DE testfw         $R0 00058:
00005 00048 : 0A4 gosub          00060:
00005 00050 : 0C2 jump           00060:
00005 00058 : 0A4 gosub          00062:

00006: STOP
00006 00060 : 190 stop


With the speed of today's machines it would be hard to find a place where that performance makes a difference.

Rocket could theoretically clean up both (or either independently) if the compiler was smart enough:

1. to know that a logical test outcome was predestined at compile time (It already does that sort of thing in other situations.). Then it could compile only 1 of the 2 paths the testfw takes. (e.g. 0020x). Same for IF, WHILE, or UNTIL constructs.

2. To recognize the final CASE before the END CASE never needs to jump (e.g., 0030x).

I wonder if we've already wasted more electrical & biological energy by me writing this email, dispersing it around the globe, and you reading it, than all the machine cycles wasted executing the 2 worthless tests in all the object scattered around the universe that Rocket could theoretically optimize.

cds


_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to