On Thu, 27 Jul 2023, Sunil Pandey wrote: > Ffsll is one of the benchmark tests in the phoronix test suite, not > sure how much it matters to the application. Lots of people involved > in phoronix benchmark testing/tracking and this kind of random perf > behavior wastes their time. Ah, I see — PTS runs Glibc benchtests (which use -fno-builtin). > Again I'm not against GCC, but if this function exists in glibc, I don't > see any harm in fixing it. Sure. But as Richard seems to be pointing out, the function seems needlessly obfuscated (even the first comment is wrong!). So if Noah's suggestion is not accepted, I can offer the following cleaned-up variant: int ffsll (long long int x) { int cnt; asm ("bsfq %1,%q0\n" /* Count low bits in X and store in %0. */ "cmovel %2,%0\n" /* If number was zero, use -1 as result. */ : "=&r" (cnt) : "r" (x), "r" (-1)); return cnt + 1; } (note that initial bsfq has an undesirable false dependency on the output operand, and Noah's variant fixes that too) Alexander