
10 Sep
2009
10 Sep
'09
5:31 p.m.
traditionaly min() has an implementation like
template<typename type> inline type min(type a, type b) { return a<b ? a : b; }
well, depending on your compiler optimization and cpu architecture, the compiler is able to optimize it, removing the branch ... e.g. different revisions of sse provide opcodes for min/max of floats/doubles and different kinds of integers ... in those cases, your branchless code may be even slower, unless it isn't optimized to use these instructions as well :) tim -- tim@klingt.org http://tim.klingt.org The composer makes plans, music laughs. Morton Feldman