[PATCH] PR90838: Support ctz idioms

Wilco Dijkstra Wilco.Dijkstra@arm.com
Wed Nov 13 12:42:00 GMT 2019


Hi Segher,

> Out of interest, what uses this?  I have never seen it before.

It's used in sjeng in SPEC and gives a 2% speedup on Cortex-A57.
Tricks like this used to be very common 20 years ago since a loop or binary search
is way too slow and few CPUs supported fast clz/ctz instructions. It's one of those
instructions you rarely need, but when you do, performance is absolutely critical...

As Jakub mentioned in the PR, https://doc.lagout.org/security/Hackers%20Delight.pdf
is a good resource for these bit tricks.

Cheers,
Wilco




More information about the Gcc-patches mailing list