How to set REX prefix when using RDRAND?

Jeffrey Walton noloader@gmail.com
Mon Oct 12 08:34:00 GMT 2015


I'm not able to compile a program that uses `rdrand` and a word64 due
to "Error: operand size mismatch for `rdrand'". If I try to explicitly
use `rdrandq` and the word64, then it results in
"Error: invalid instruction suffix for `rdrand'"

According to the Intel manual [1], RDRAND operates on 32-bit operands
even in 64-bit mode. The manual goes onto to say we should use the REX
prefix to operate on 64-bit operands.

How do I set REX prefix when using RDRAND and the inline assembler?

Thanks in advance.

[1] Intel® 64 and IA-32 Architectures Software Developer’s Manual,
Volume 2, page 4-298
(https://www-ssl.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf)



More information about the Gcc-help mailing list