|
Boost : |
Subject: Re: [boost] non-branching min()
From: Tim Blechmann (tim_at_[hidden])
Date: 2009-09-10 13:31:33
> 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_at_[hidden] http://tim.klingt.org The composer makes plans, music laughs. Morton Feldman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk