[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86: use tzcnt instead of bsf
commit b18b6daf65554fd9e1b6008513bfd50a7ef5d3e9 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon Jan 26 12:50:21 2015 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Jan 26 12:50:21 2015 +0100 x86: use tzcnt instead of bsf Following a compiler change done in 2012, make use of the fact that for non-zero input BSF and TZCNT produce the same numeric result (EFLAGS setting differs), and that CPUs not knowing of TZCNT will treat the instruction as BSF (i.e. ignore what looks like a REP prefix to them). The assumption here is that TZCNT would never have worse performance than BSF. Also extend the asm() input in find_first_set_bit() to allow memory operands. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/x86/bitops.c | 2 +- xen/arch/x86/hvm/vpic.c | 2 +- xen/include/asm-x86/bitops.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/bitops.c b/xen/arch/x86/bitops.c index c037567..f6ee715 100644 --- a/xen/arch/x86/bitops.c +++ b/xen/arch/x86/bitops.c @@ -62,7 +62,7 @@ unsigned int __find_first_zero_bit( " je 2f\n\t" " xor -"STR(BITS_PER_LONG/8)"(%2),%3\n\t" " jz 1b\n\t" - " bsf %3,%0\n\t" + " rep; bsf %3,%0\n\t" " lea -"STR(BITS_PER_LONG/8)"(%2),%2\n\t" "2: sub %%ebx,%%edi\n\t" " shl $3,%%edi\n\t" diff --git a/xen/arch/x86/hvm/vpic.c b/xen/arch/x86/hvm/vpic.c index 2c6e6e5..d72b6ff 100644 --- a/xen/arch/x86/hvm/vpic.c +++ b/xen/arch/x86/hvm/vpic.c @@ -56,7 +56,7 @@ static int vpic_get_priority(struct hvm_hw_vpic *vpic, uint8_t mask) return VPIC_PRIO_NONE; /* prio = ffs(mask ROR vpic->priority_add); */ - asm ( "ror %%cl,%b1 ; bsf %1,%0" + asm ( "ror %%cl,%b1 ; rep; bsf %1,%0" : "=r" (prio) : "q" ((uint32_t)mask), "c" (vpic->priority_add) ); return prio; } diff --git a/xen/include/asm-x86/bitops.h b/xen/include/asm-x86/bitops.h index 099a74c..6f0f34b 100644 --- a/xen/include/asm-x86/bitops.h +++ b/xen/include/asm-x86/bitops.h @@ -391,7 +391,7 @@ static inline unsigned int __scanbit(unsigned long val, unsigned long max) */ static inline unsigned int find_first_set_bit(unsigned long word) { - asm ( "bsf %1,%0" : "=r" (word) : "r" (word) ); + asm ( "rep; bsf %1,%0" : "=r" (word) : "rm" (word) ); return (unsigned int)word; } -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |