This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to set REX prefix when using RDRAND?
- From: Florian Weimer <fweimer at redhat dot com>
- To: noloader at gmail dot com
- Cc: Mason <slash dot tmp at free dot fr>, GCC help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 13 Oct 2015 13:24:23 +0200
- Subject: Re: How to set REX prefix when using RDRAND?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8notjAYqQ4FRMvtP8rV+Ks=G7i83mbae_ttAnBMJz5rEg at mail dot gmail dot com> <561B7D6A dot 4000709 at free dot fr> <CAH8yC8=QOareae4u63-tSxPhLz_RtYOBrvzTz_8mMCmgm8cUfg at mail dot gmail dot com> <561C10C9 dot 10101 at redhat dot com> <CAH8yC8nQ6tvHc56v+=3sH9kVmyMwFAKRTzwnj8E5YmvvEk2BdQ at mail dot gmail dot com>
On 10/12/2015 11:40 PM, Jeffrey Walton wrote:
> On Mon, Oct 12, 2015 at 3:58 PM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 10/12/2015 07:41 PM, Jeffrey Walton wrote:
>>
>>> while (size && safety)
>>> {
>>> char rc;
>>> __asm__ volatile(
>>> #if BOOL_X86
>>> "rdrandl %0 ; setc %1"
>>> #else
>>> "rdrandq %0 ; setc %1"
>>> #endif
>>> : "=rm" (val), "=qm" (rc)
>>> :
>>> : "cc"
>>> );
>>
>> I don't think RDRAND supports memory operand, so the constraint is
>> incorrect, and a width suffix is not required.
>
> Thanks Florian. You might be right... I'll have to check the Intel manual again.
>
> According to the Intel manual [1], it looks like its a R/W
> instruction. But I can switch up to R-only if its needed...
The instruction has an r/m byte, but it's documented to take only a
register argument: The opcode table lists âRDRAND r32â, but not âRDRAND
r/m32â.
Florian