Re: [Algorithms] How to get 3dvector largest coordinate index?
Brought to you by:
vexxed72
From: Alen L. <ale...@cr...> - 2009-02-27 07:29:43
|
Jon wrote: > I've never found this to show up in any profile, and on x86, I believe a > competent compiler generates cmov. I got burned with this some time ago, so I'll throw in a warning: A competent compiler (e.g. icc) does indeed, but a very common one (msvc) does not (at least not in VC8.0, which was the latest I tested for that). The compiler team says that it does in some cases, but I haven't been able to make it do so. Ever. It certainly doesn't do so for x<y?x:y or for x<y?0:1. If someone does know how to do that, please let me know. Btw, I've actually had cases where the lack of cmov did show on the profile (BIH raycaster), and manually rewritten code using SSE (one float per register!) was significantly faster, so cache performance was not an issue there. Interestingly enough, in many cases like this, when I try to recompile with icc, it turns out its code is very similar to my hand-optimized one. And to add one more idea for the OP, if you feel confident in the normality of the inputs, you can try using float-as-integer comparing tricks, but the speed is better only if you don't generate the input using float operations just before doing the compares (i.e. the input is already in memory). HTH, Alen |