Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utah-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!vax135!cornell!uw-beaver!tektronix!hplabs!hao!seismo!utah-cs!4bsd-f77 From: 4bsd-f77@utah-cs.UUCP (4.2 BSD f77 bug reports) Newsgroups: net.lang.f77,net.bugs.4bsd Subject: [4bsd-f77 #36] f77 fix for COMMON needs to be extended to EQUIVALENCE Message-ID: <4bsd-f77-36@utah-cs.UUCP> Date: Wed, 29-Aug-84 19:09:37 EDT Article-I.D.: utah-cs.4bsd-f77-36 Posted: Wed Aug 29 19:09:37 1984 Date-Received: Sat, 1-Sep-84 10:33:56 EDT Sender: donn@utah-cs.arpa Organization: University of Utah CS Dept Lines: 77 From: Donn Seeley Subject: The f77 fix for COMMON needs to be extended to EQUIVALENCE Index: usr.bin/f77/src/f77pass1/optcse.c 4.2BSD Description: The fix given in 4bsd-f77 #18 (<163@sdchema.UUCP>, titled 'Revision to common subexpression bug fix in f77') is incomplete -- the same problems that occur with common subexpressions and COMMON variables also occur with EQUIVALENCEd variables. This bug was observed and fixed by Jerry Berkman at UC Berkeley. Repeat-By: Compile the following program (from Jerry Berkman) with the optimizer on: ---------------------------------------------------------------- c sees common subexp where none exists double precision a0,a1, b0,b1, z0(2),z1(2) double complex a(2), za0,za1 equivalence (za0,z0(1)),(za1,z1(1)), 1 (a0,z0(1)),(b0,z0(2)), (a1,z1(1)),(b1,z1(2)) data a/ (1.0d0,2.0d0), (12.2d0,14.8d0)/ c za0 = a(1) za1 = a(2) a(1) = dcmplx(a0+a1,b0+b1) a(2) = dcmplx(a0-a1,b0-b1) print *, a(1), a(2) end ---------------------------------------------------------------- When run, this program prints the following: ---------------------------------------------------------------- ( 13.200000000000, 13.200000000000) ( -11.200000000000, -11.200000000000) ---------------------------------------------------------------- But it's supposed to print: ---------------------------------------------------------------- ( 13.200000000000, 16.800000000000) ( -11.200000000000, -12.800000000000) ---------------------------------------------------------------- Fix: The problem is exactly the same as the problem with COMMON variables and CSE, except applied to EQUIVALENCEd variables; so I will skip the usual tedious explanation and simply present the fix. This fix applies to the routine samebase() in f77pass1/optcse.c and must be applied AFTER the earlier fix: ---------------------------------------------------------------- *** /tmp/,RCSt1024965 Sun Aug 19 23:41:08 1984 --- optcse.c Sat Aug 4 20:39:58 1984 *************** *** 404,409 case TADDR : if (ep1->addrblock.vstg == ep2->addrblock.vstg) { switch(ep1->addrblock.vstg) { case STGCOMMON: if (ep1->addrblock.memno == ep2->addrblock.memno && ISCONST(ep1->addrblock.memoffset) && --- 409,415 ----- case TADDR : if (ep1->addrblock.vstg == ep2->addrblock.vstg) { switch(ep1->addrblock.vstg) { + case STGEQUIV: case STGCOMMON: if (ep1->addrblock.memno == ep2->addrblock.memno && ISCONST(ep1->addrblock.memoffset) && ---------------------------------------------------------------- Donn Seeley University of Utah CS Dept donn@utah-cs.arpa 40 46' 6"N 111 50' 34"W (801) 581-5668 decvax!utah-cs!donn