A little warning in GMP.h
Brian Hurt
bhurt at spnz.org
Sat Sep 25 02:47:08 CEST 2004
On 25 Sep 2004, Torbjorn Granlund wrote:
> At least in the past GCC didn't always handle that as one would
> wish. (This is target dependent, the GCC macro BRANCH_COST need
> to be set properly for GCC to do extra computatiuons for avoiding
> branches.)
And in the past eliminating branchs wasn't that big of a problem. It's
only been recently that we've started getting CPUs where the branch
mispredict cost was extreme.
>
> The advantage of the branched version is that it doesn't depend
> upon the system being twos complement. And gcc (at least version 3.2.2)
> emits branchless code using the sete instruction with just -O2.
>
> On which platforms?
This was X86/Linux/Redhat 9.0.
>
> Another alternative would be:
> return __gmp_l & (((mp_limb_t) (__gmp_n == 0)) - 1u);
>
> Another alternative would be to have a signed mp_limb_t type around.
>
> We're not going to go through the GMP code just to work around a
> bogus Microsoft compiler warning. Please use GCC for compiling
> GMP if Microsoft's compiler's bogus warnings bother you.
This isn't a microsoft-ism. This is a code quality question.
It's not a big deal to me- I don't have to maintain the code. I just
thought I'd raise the question.
--
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
- Gene Spafford
Brian
More information about the gmp-discuss
mailing list