--- old/src/cpu/x86/vm/assembler_x86.cpp 2014-03-24 17:32:13.000000000 -0700 +++ new/src/cpu/x86/vm/assembler_x86.cpp 2014-03-24 17:32:13.000000000 -0700 @@ -1112,8 +1112,12 @@ } void Assembler::bsrl(Register dst, Register src) { - assert(!VM_Version::supports_lzcnt(), "encoding is treated as LZCNT"); +#ifdef ASSERT + address prefix = pc(); +#endif int encode = prefix_and_encode(dst->encoding(), src->encoding()); + // x86 oddity: bsr with a rep prefix (f3) is lzcnt when CPU supports it + assert(!VM_Version::supports_lzcnt() || pc() == prefix || *prefix != REP, "encoding is treated as LZCNT with REP prefix"); emit_int8(0x0F); emit_int8((unsigned char)0xBD); emit_int8((unsigned char)(0xC0 | encode)); @@ -4977,8 +4981,12 @@ } void Assembler::bsrq(Register dst, Register src) { - assert(!VM_Version::supports_lzcnt(), "encoding is treated as LZCNT"); +#ifdef ASSERT + address prefix = pc(); +#endif int encode = prefixq_and_encode(dst->encoding(), src->encoding()); + // x86 oddity: bsr with a rep prefix (f3) is lzcnt when CPU supports it + assert(!VM_Version::supports_lzcnt() || pc() == prefix || *prefix != REP, "encoding is treated as LZCNT with REP prefix"); emit_int8(0x0F); emit_int8((unsigned char)0xBD); emit_int8((unsigned char)(0xC0 | encode));