Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.bugs.4bsd Subject: Re: (more) missed optimizations in pcc Message-ID: <1279@umcp-cs.UUCP> Date: Wed, 21-Nov-84 00:12:19 EST Article-I.D.: umcp-cs.1279 Posted: Wed Nov 21 00:12:19 1984 Date-Received: Thu, 22-Nov-84 06:02:55 EST References: <1214@umcp-cs.UUCP> <1277@umcp-cs.UUCP> Distribution: net Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 50 (Here we go again...) Index: lib/pcc/local.c 4.2BSD Fix Description: The Vax compiler generates a call to ``urem'' to perform unsigned mod (%) operations, even in cases where the result is guaranteed to be the same as the result of a mask. For example, ``unsigned u; int i; i = u % 8;'' is such an expression. Repeat-By: Examine the compiler output for mod with unsigned LHS. Fix: The same as last time, but with an additional check to ensure that the LHS is an unsigned type. RCS file: RCS/local.c,v retrieving revision 1.1 diff -c1 -r1.1 local.c *** /tmp/,RCSt1006868 Tue Nov 20 23:42:52 1984 --- local.c Tue Nov 20 23:42:32 1984 *************** *** 151,152 case FLD: --- 151,163 ----- + case MOD: + case ASG MOD: + /* convert %(const power of two) to &(mask) */ + /* mod by one is done elsewhere */ + if( ISUNSIGNED(p->in.left->in.type) && + nncon( p->in.right ) && ispow2( p->in.right->tn.lval )>0 ){ + p->in.op = p->in.op==MOD ? AND : ASG AND; + p->in.right->tn.lval--; + } + break; + case FLD: I guess that's the best that can be done, short of using ?: . . . . -- (This line accidently left nonblank.) In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690 UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland