Boost logo

Boost :

Subject: Re: [boost] non-branching min()
From: Bo Persson (bop_at_[hidden])
Date: 2009-09-11 12:25:03


DE wrote:
> on 11.09.2009 at 3:19
> Cory Nelson wrote :
>> I'm curious, have you actually tried to look at the generated
>> instructions?
> of course
>
>> Because on a 686+ this should compile this into two
>> non-branching instructions for min():
>> cmp a, b
>> cmova a, b
>> And the same thing but with cmovb for max().
> neither icc11 nor msvc80 generate such instructions
> msvc generates a conditional jump and icc generates code "without
> branches but with the sbb asm instruction" (c) Joel Falcou
>

I believe the conditional move introduces a dependency that is about
as bad as a conditional jump. It also limits the code to the latest
processor models.

The compilers generally try to avoid this situation. :-)

Bo Persson


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk