[PATCH] D84717: [ADT][BitVector][NFC] Merge find_first_in() / find_first_unset_in()
Stefanos Baziotis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 18:32:47 PDT 2020
baziotis added a comment.
In D84717#2179172 <https://reviews.llvm.org/D84717#2179172>, @Meinersbur wrote:
> LGTM
>
> In D84717#2178016 <https://reviews.llvm.org/D84717#2178016>, @baziotis wrote:
>
>> One proposal by a friend of mine, GeorgeLS <https://github.com/GeorgeLS>, is that we can make a wrapper in which instead of passing a `bool`, we pass a `BitWord`.
>> And then we XOR with this `BitWord` every `BitWord` we read from `Bits`. So, the passed `BitWord` acts conditionally. If we want the "unset" version, we pass `~0`.
>> If we want the "set" version, we pass `0`.
>
> An optimizing compiler might already do this if it thinks it is profitable. That is, InstCombine
>
> if (!Set)
> Copy = ~Copy;
>
> to
>
> Mask = Set ? 0 : -1;
> Copy ^= Mask;
>
> and hoist Mask out of the loop.
>
> However, unless you show that there is a relevant performance difference, I don't have a preference for either version.
Oh well, indeed: https://godbolt.org/z/9KsYKa
Thanks, I didn't think about it.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84717/new/
https://reviews.llvm.org/D84717
More information about the llvm-commits
mailing list