/* Bit set in the bytes that have a zero */ staticinlinelong prep_zero_mask(unsignedlong val, unsignedlong rhs, conststruct word_at_a_time *c)
{ unsignedlong mask = (val & c->low_bits) + c->low_bits; return ~(mask | rhs);
}
/* * The optimal byte mask counting is probably going to be something * that is architecture-specific. If you have a reliably fast * bit count instruction, that might be better than the multiply * and shift, for example.
*/ struct word_at_a_time { constunsignedlong one_bits, high_bits;
};
/* * Jan Achrenius on G+: microoptimized version of * the simpler "(mask & ONEBYTES) * ONEBYTES >> 56" * that works for the bytemasks without having to * mask them first.
*/ staticinlinelong count_masked_bytes(unsignedlong mask)
{ return mask*0x0001020304050608ul >> 56;
}
#else/* 32-bit case */
/* Carl Chatfield / Jan Achrenius G+ version for 32-bit */ staticinlinelong count_masked_bytes(long mask)
{ /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */ long a = (0x0ff0001+mask) >> 23; /* Fix the 1 for 00 case */ return a & mask;
}
#endif
/* Return nonzero if it has a zero */ staticinlineunsignedlong has_zero(unsignedlong a, unsignedlong *bits, conststruct word_at_a_time *c)
{ unsignedlong mask = ((a - c->one_bits) & ~a) & c->high_bits;
*bits = mask; return mask;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.