Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!occrsh!uokmax!rmtodd From: rmtodd@uokmax.UUCP (Richard Michael Todd) Newsgroups: comp.lang.c Subject: Re: noalias; parens honored Message-ID: <978@uokmax.UUCP> Date: 19 Dec 87 04:17:59 GMT References: <6829@brl-smoke.ARPA> <2845@zeus.TEK.COM> Reply-To: rmtodd@uokmax.UUCP () Organization: University of Oklahoma, Norman, OK Lines: 118 Keywords: ANSI C standard Summary: Some compilers are capable of doing such optimizations In article <2845@zeus.TEK.COM> dant@tekla.UUCP (Dan Tilque) writes: >It also seems pretty late in the process to be making major changes like >adding keywords. Is there any current compiler (i.e. prior art) which >uses 'noalias'? If so, how much better is the code generated by it? I don't know of any compiler that uses the 'noalias' keyword, but both Aztec and Turbo C for the PC have a command line option to specify this type of 'noalias' optimization for an entire file. For Aztec it's '+a', for Turbo it's '-Z'. As for how well it works, I didn't know offhand, but I just did a little expirementing with Aztec C, compiling some C files both with and without the +a optimization, and running diff on the assembly code output. The files I tried came from MicroEmacs 3.9 (I guess that counts as "real world code" :-) I tested three files in all; the first two showed no difference whatsoever with the optimization on and off. The third file I tried, buffer.c, showed some optimization at various places. For the overly-curious, part of the diff listing between the files is shown below. The part marked with '<' is the no-optimization version, the part marked with '>' is the version with the no-alias optimization turned on. Mostly the optimizations look to be simply the result of the compiler keeping better track of stuff left in registers by previous expressions' code. 1148,1149c1140,1141 < push word ptr blistp_+2 < push word ptr blistp_ --- > push es > push bx 1805,1806c1797,1798 < ^ mov dx,word ptr -2[bp] < mov ax,word ptr -4[bp] --- > ^ mov dx,es > mov ax,bx 1821,1827c1813,1817 < mov ax,es:word ptr 4[bx] < mov dx,es:word ptr 6[bx] < mov cx,es:word ptr 16[bx] < mov bx,es:word ptr 18[bx] < cmp dx,bx < jne $20067 < cmp ax,cx --- > mov cx,es:word ptr 4[bx] > mov bx,es:word ptr 6[bx] > cmp bx,dx > jne $20067 > cmp cx,ax 2073,2074c2063,2064 < ^ mov dx,word ptr -2[bp] < mov ax,word ptr -4[bp] --- > ^ mov dx,es > mov ax,bx 2125,2126c2115,2116 < ^ mov dx,word ptr -2[bp] < mov ax,word ptr -4[bp] --- > ^ mov dx,es > mov ax,bx 2140d2129 < les bx,dword ptr -4[bp] 2144,2155c2133,2140 < ^ les bx,dword ptr -4[bp] < mov es:word ptr 8[bx],00H < ; bp->b_markp = NULL; < ^ les bx,dword ptr -4[bp] < mov es:word ptr 12[bx],00H < mov es:word ptr 10[bx],00H < ; bp->b_marko = 0; < ^ les bx,dword ptr -4[bp] < mov es:word ptr 14[bx],00H < ; bp->b_flag = bflag; < ^ mov al,byte ptr 12[bp] < les bx,dword ptr -4[bp] --- > ^ mov es:word ptr 8[bx],00H > ; bp->b_markp = NULL; > ^ mov es:word ptr 12[bx],00H > mov es:word ptr 10[bx],00H > ; bp->b_marko = 0; > ^ mov es:word ptr 14[bx],00H > ; bp->b_flag = bflag; > ^ mov al,byte ptr 12[bp] 2159,2163c2144,2146 < les bx,dword ptr -4[bp] < mov es:word ptr 23[bx],ax < ; bp->b_nwnd = 0; < ^ les bx,dword ptr -4[bp] < mov es:byte ptr 21[bx],00H --- > mov es:word ptr 23[bx],ax > ; bp->b_nwnd = 0; > ^ mov es:byte ptr 21[bx],00H 2167d2149 < les bx,dword ptr -4[bp] 2174,2176c2156,2158 < mov dx,word ptr -2[bp] < mov ax,word ptr -4[bp] < add ax,25 --- > add bx,25 > mov dx,es > mov ax,bx 2199c2181,2182 < les bx,dword ptr -12[bp] --- > mov es,dx > mov bx,ax 2203,2205c2186,2187 < ^ mov dx,word ptr -10[bp] < mov ax,word ptr -12[bp] < les bx,dword ptr -12[bp] --- > ^ mov dx,es > mov ax,bx ___________________________________________________________________________ Richard Todd USSnail:820 Annie Court,Norman OK 73069 UUCP: {allegra!cbosgd|ihnp4}!occrsh!uokmax!rmtodd