public static uint bits_depositparallel(uint x, uint mask) { if (Bmi2.IsBmi2Supported) { return(Bmi2.pdep_u32(x, mask)); } else { uint result = 0; for (uint i = 1; mask != 0; i += i) { if ((x & i) != 0) { result |= bits_extractlowest(mask); } else { } mask = bits_resetlowest(mask); } return(result); } }