Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!usc!apple!well!rchrd From: rchrd@well.sf.ca.us (Richard Friedman) Newsgroups: comp.lang.fortran Subject: Re: why does optimization take so long ? Message-ID: <24940@well.sf.ca.us> Date: 22 May 91 05:47:53 GMT References: <1236@nikhefh.nikhef.nl> Lines: 24 t19@nikhefh.nikhef.nl (Geert J v Oldenborgh) writes: >I am curious whether any of you know why compiling certain routines with a -O >flag takes a semi-infinite amount of time on certain computers > qqgg= n1i*n2i*pbqi*ptqi * ( - 2*pnpe*pbpt**2*qk + 2*pnpe* > + qk*mb2*mt2 + 2*pnpb*pepb*pbpt*qk - 2*pnpb*pepb*qk*mt2 + 2* > + pnpb*pept*pbpt*qk + 4*pnpb*pept*pbpt**2 - pnpb*pept*qk*mb2 - > ...400 similar lines... >As a lot of the time is spent here I'd like to be able to optimize it. For starters, just try yourself to find all the common subexpressions in all that garbage so you can minimize the number of unnecessary computations of the same things. Compilers also have to be smart enough to detect that pnpb*pept*pbpt*qk is the same as pept*qk*pnpb*pnbt. That generates lots of linked lists to be searched. If you could get your symbolic code generator to generate stores into temporaries for these subexpressions, I'm sure the optimizer would speed up for you. -- /\=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=/\ \/Richard Friedman RCHRD | rchrd@well.sf.ca.us \/ /\Box 9584 Berkeley CA 94709-0584 | or well!rchrd@apple.com /\ \/=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\/