[C++] Add software implementation of PDEP and reenable BMI2 code paths on all AVX2 CPUs
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the enhancement requested
In #37610 we had to guard some code paths on the presence of the BMI2 instruction sets, because those code paths use two BMI2 instrinsics (the PDEP and PEXT instructions) that are not efficiently implemented on all modern x86 CPUs (and that can be absent on a few rare ones).
However, we already have a reasonably good software emulation of PEXT [in another place](https://github.com/apache/arrow/blob/a8a604cfc5bc8d05ca3b1ef1388e6efd8ba6e5cd/cpp/src/parquet/level_conversion_inc.h#L37-L257) and it should be relatively easy to write a software emulation of PDEP using the exact same approach (lookup table to process 5 bits at a time).
This would allow re-enabling the aforementioned codepaths on all CPUs supporting AVX2, even if they don't have an (efficient) BMI2 implementation.
This includes AMD CPUs since at least 2017.
### Component(s)
C++
Contributor guide
Assessment
This issue has not been assessed yet.