Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!uw-beaver!cornell!rochester!ur-tut!sunybcs!boulder!hao!oddjob!mimsy!eneevax!umd5!brl-adm!adm!TLIMONCE%DREW.BITNET@CUNYVM.CUNY.EDU From: TLIMONCE%DREW.BITNET@CUNYVM.CUNY.EDU Newsgroups: comp.lang.c Subject: Re: a couple quickies / foo(&i) Message-ID: <11189@brl-adm.ARPA> Date: 9 Jan 88 05:36:16 GMT Sender: news@brl-adm.ARPA Lines: 48 A while ago I wrote: > for (i=0; i==100; i++) foo(&i); Yes, I did mean: for (i=0; i<100; i++) foo(&i); Sorry for the typo and thanks for the answers (and interesting insights to what both would do. I must have posted that one late at night because I totally forgot that for() is expanded to while() and that made the answer obvious. Now, let's look at a not-so-obvious use of noalias: noalias int i; for (i=0; i<100; i++) {...anything...} Because I told the compiler noalias it knows that I will not be doing anything funny to i. A compiler can rightly ignore "noalias" since the default is the "safe" method. But look at what a 1990's compiler could do here. If the compiler notices that I don't modify i in the loop and if the target machine has a compare_to_zero function that is many times faster than compare_to_an_integer the code can be re-written to be: noalias int i, _hidden_i; i=0; _hidden_i=100; while (_hidden_i) {...anything...; i++; --_hidden_i;} ...which could be very-much faster on the target. This level of optimization is something that has never before been do-able until now. Of course, with a _lot_ of extra programming (motion tracing, etc) the compiler may have surmised that this was possible. (I bet that a good motion tracer could find huge numbers of variables that could be ALSO go as noalias as the programmer didn't recognize. ...but a good motion tracer will not be seen in many compilers until the late (?) 1990's) There you have it folks. A real purpose for noalias that most people didn't even think of. T. Limoncelli Drew U/Box 1060/Madison NJ 07940 Bitnet: tlimonce@drew.BITNET Disclaimer: These are my views, not my employer or Drew Univesity. "Any typos should be reported to my mother, who checked all my papers until I got a spelling checker in 8th grade." --------------------------------------------------------------------------