Hi, On 2022-08-05 13:25:10 -0700, Nathan Bossart wrote: > I went ahead and renamed it to pg_lfind32() and switched it back to > returning the pointer. That felt the cleanest from the naming perspective, > but as Andres noted, it might not be as fast as just looking for the > presence of the element. I modified my small testing program to perform > many searches on small arrays, and I wasn't able to identify any impact, so > perhaps thіs is good enough.
Why on small arrays? I'd expect a difference mainly if it there's at least a few iterations. But mainly I'd expect to find a difference if the SIMD code were optimized a further on the basis of not needing to return the offset. E.g. by replacing _mm_packs_epi32 with _mm_or_si128, that's cheaper. - Andres