__parityti2(), __paritydi2() and __paritysi2() vs. __builtin_parity

Hi @ll,

compiler-rt/lib/builtins/parityti2.c
compiler-rt/lib/builtins/paritydi2.c
compiler-rt/lib/builtins/paritysi2.c

implement the parity function as matroschka:

si_int
__paritysi2(si_int a)
{
    su_int x = (su_int)a;
    x ^= x >> 16;
    x ^= x >> 8;
    x ^= x >> 4;
    return (0x6996 >> (x & 0xF)) & 1; // see optimisation below!
}

si_int
__paritydi2(di_int a)
{
    dwords x;
    x.all = a;
    return __paritysi2(x.s.high ^ x.s.low);
}

si_int
__parityti2(ti_int a)
{
    twords x;
    x.all = a;
    return __paritydi2(x.s.high ^ x.s.low);
}

Questions:

I don’t believe clang/llvm will ever emit a call to the parity library routines today. But it might be needed so we can say that we match the libgcc interface. gcc doesn’t use it for x86 either as far as I know. And I don’t know if they have it in their x86 libgcc. But it might be easier for compiler-rt to be a superset of libgcc rather than trying to track exactly what they have on each target.

Not sure about the inlining question.