Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pilchuck!dataio!fnx!nazgul!bright From: bright@nazgul.UUCP (Walter Bright) Newsgroups: comp.lang.c Subject: Re: Help with casts Message-ID: <278@nazgul.UUCP> Date: 5 Mar 91 19:14:56 GMT References: <1991Feb21.040145.8678@cec1.wustl.edu> <409@ceco.ceco.com> <339@smds.UUCP> <414@ceco.ceco.com> <1991Feb25.143544.11950@watdragon.waterloo.edu> Reply-To: bright@nazgul.UUCP (Walter Bright) Organization: Zortech, Seattle Lines: 19 /Bear in mind that C is one of the hardest languages in the world to /optimize. For instance, in pascal the index of a for loop cannot be referenced /outside of that loop, thus the code can be optimized by making that index a /register variable. ... C is hard to optimize, but that is because of the aliasing problem, not identification of loop variables. Standard textbook algorithms exist (see the Dragon Book) which can identify the loop variable(s) from out of a rat's nest of goto's. It is also easilly determined if the loop variable is used after exit of the loop or not. In fact, I'd say it was easier and more reliable than fiddling with the loop constructs in a parse tree... The right way to optimize is to convert everything to a bunch of expressions connected by goto's. Then analyze the goto's to determine the loops and everything else needed. I've implemented these algorithms in Zortech's optimizer, and they do work. They did have to be modified, however, to support the idea that ints and pointers are not the same size!