Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: serious code generation bug in Lightspeed C Message-ID: <6343@hoptoad.uucp> Date: 20 Jan 89 22:03:12 GMT References: <1112@dogie.edu> <6337@hoptoad.uucp> <5623@phoenix.Princeton.EDU> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 54 In article <6337@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: >Now, look at the three >notes under "The Lisa Pascal compiler frequently dereferences handles >during its normal operation." What is the first one? That's right, it >is about the WITH statement, and has no applicability to any C compiler. In article <5623@phoenix.Princeton.EDU> mbkennel@phoenix.Princeton.EDU (Matthew B. Kennel) writes: >An intelligent C compiler should perform this optimization automatically, >i.e. reduction of common subexpressions. I really can't agree. That changes the language definition. Unless you mean something different from an implicit WITH statement; if you mean that common subexpressions are reduced at the code generation level, so that two references to (*h)->m are only computed once, there are also problems with that if any routines with side effects are called between the two references. >> What is the third one? Yes, it concerns implicit passing by >>reference of structures, something which no C compiler does, and again >>has absolutely nothing to do with C. > >There is no reason why a C compiler couldn't do it if it could figure >out that the results would conform to the standard. Suppose it realized >that the called function never changed any of the values of the passed >structure, but only read its contents. I would think it a reasonable >optimization to only pass the address of this structure and tweak off >the values from that instead of copying the whole thing onto the stack >or something like that. Given global optimization, that is, optimization that computes the attributes of various routines and calls and optimizes the entire linked body of software based on that, that's true. However, such an optimizer would also be smart enough to avoid dereferencing problems in that case. Closer to reality, I've never seen any globally optimizing C compiler, only peephole optimized ones. >Why does LSC generate such LAME code? Does it optimize ANYTHING? >Sorry to be so disrespectful of an otherwise fine product, but the code >generator is definitely NOT up to contemporary standards, even on >microcomputers. True, but in its defense, it is trying for speed and an optimizing pass would slow things down a lot. Still, for production software, they should have an optional optimizing pass. I mean, forget contemporary standards, register optimization was pretty thoroughly understood at the end of the 1970's. There's no excuse for doing everything on the stack any more. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "But don't you see, the color of wine in a crystal glass can be spiritual. The look in a face, the music of a violin. A Paris theater can be infused with the spiritual for all its solidity." -- Lestat, THE VAPIRE LESTAT, Anne Rice