Author: Gerd Isenberg
Date: 10:37:49 12/04/03
Go up one level in this thread
>OK. If I interpret that correctly, if I occasionally call this with a >zero value, the cmov might be better due to avoiding the mis-predicted >branch. But if it is always non-zero, then the jnz is better. > > >> >>> >>> bsr rdx, rax >>> jnz 1f ; 1 cycle >>> mov edx, -1 ; skipped >>>1: mov eax, 63 ; 1 cycle >>> sub eax, rdx ; 1 cycle >>> >>> >>> bsr rdx, rax >>> mov eax, -1 ; 1 cycle >>> cmovz edx, eax ; 1 cycle >>> mov eax, 63 ; 1 cycle >>> sub eax, rdx ; 1 cycle Can you already inspect the generated code? Does int (32-bit)-functions use "ret eax" or the one byte prefixed "ret rax"? I guess, after the bsr/bsf, shorter 32-bit instructions are fine, specially if unsigned (due to the signed int index penalty).
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.