BMI2 (Bit Manipulation Instructions 2) には PEXT/PDEP という命令があって、32/64 ビット値の中から指定したビット群を取ってきて下に詰めて取得する、という処理(とその逆)が1命令でできます。Intel だと Haswell 以降で使えます。

Read the rest of this entry