LZCNT on Core i7

LZCNT on Core i7

Let me start with: I know that LZCNT is not supported on the Core i7.

However when I run theinstruction on my Core i7 I do not as I expect get an illegal instruction exception.
Instead it performs a BSR instruction.
This is while working in 64 bit mode and using 64 bit registers.

Is this a bug, expected behaior or is running unsupported instructions undefined (and this is therefore OK)?

For reference the opcodes are:
LZCNT: 0xBD (Same as BSR but has a prefix of 0xF3)

Any feedback would be helpful.


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

It is not a bug. AMD decided to take a valid encoding (prefix+ BSR) that was unlikely to be used by software and repurpose it for LZCNT. The prefix had no funtional effect on BSR.

Leave a Comment

Please sign in to add a comment. Not a member? Join today