At 13:57 -0700 10/26/04, Sanjay Patel wrote:
> > > I wanted to mention it and then forgot, but yes, those variables are
>> > of external scope, as they are instance variables of an objc object.
>> > They are thus members of a struct, which is passed by ref to the
>> > function (as objc objects are pointers to struct). So yes, this is
>> > probably the problem. I never thought of it in this particular
>> > configuration... Is the fix to use a local variable instead? Something
>
>Yes. The compiler is reloading your pointers on every loop iteration because
>it can't tell whether your stores alias to those pointers (which means the
>ptr value could change from one iteration to the next).
>
>Shark says:
>
>"Common causes of invariant loads within a loop are a pointer dereference
>within the loop or use of a global variable. You can eliminate this
>inefficiency by using a temporary local variable within the loop."
>
>You should consider unrolling the loop too.
>
>--Sanjay
Thanks for the explanation!
I had read Shark comments. But I did not realize the instance variable would create the problem this way. I was not using any global variable and I thought the 'pointer dereference' was about the C array itself (being a pointer), which seemed a little weird. Now, I realize the 'pointer' dereference is simply self (= struct *), and the line inside the loop depends on it.
charles
[[NB: Because I now feel a bit stupid :-/, I just want to justify my stupidity, and add that I had not really looked into this until now, because I don't have big hot spots from that problem... But the explanation will now be useful, I have one critical function that could use some of that + maybe unrolling! BTW, thanks Shark!]]
--
Charles Parnot
email@hidden
Help science go fast forward:
http://cmgm.stanford.edu/~cparnot/xgrid-stanford/
Room B157 in Beckman Center
279, Campus Drive
Stanford University
Stanford, CA 94305 (USA)
Tel +1 650 725 7754
Fax +1 650 725 8021
_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden
This email sent to email@hidden