mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The change replaces 'set bit enumeration' with arithmetic and bitwise operations. For example, the formula '(((x & -x) + x) & x) ^ x' can be used to find the rightmost contiguous bit mask. This is essentially the operation that SetBitEnumerator.findNext() performed. Removing this functionality reduces the complexity of the ClusteredBitVector (a.k.a. SpareBitVector) implementation and, more importantly, API which will make it easier to modify the implementation of spare bit masks going forward. My end goal being to make spare bit operations work more reliably on big endian systems. Side note: This change modifies the emit gather/scatter functions so that they work with an APInt, rather than a SpareBitVector, which makes these functions a bit more generic. These functions emit instructions that are essentially equivalent to the parallel bit extract/deposit (PEXT and PDEP) instructions in BMI2 on x86_64 (although we don't emit those directly currently). They also map well to bitwise manipulation instructions on other platforms (e.g. RISBG on IBM Z). So we might find uses for them outside spare bit manipulation in the future.
5.3 KiB
5.3 KiB