News for hackers. Stuff that matters.
Re:Unsigned comparisons in AVX2/SSE: a quick note by Const-me on Friday August 26, 2022 @04:25PM (#32612350)
That’s often a good way, but not necessarily the best one. On my computer with Zen3 CPU, cvtdq2ps and cvttps2dq have 3 cycles of latency each, divps up to 10 cycles, results in 16 CPU cycles in total.

When the divisor’s the same for all lanes and known at compile time, there’re tricks to reduce division to a single integer multiplication, and a few extra cheap instructions like shifts and additions. Usually faster than 16 cycles. Here’s an example, automagically made by clang 13: https://godbolt.org/z/T4TKb7oov

There are no comments on this comment yet.