Jeremy Hall <gcc.hall@xxxxxxxxx> writes: > The only spanner in the works is that this problem does NOT occur with > the similar rdtsc instruction. I wondered if rdtsc was flagged within > gcc in some way to say its output was volatile, and that perhaps this > had yet to be done with rdrand (as its a new instruction not available > for a few months until Ivy Bridge comes out). gcc doesn't know anything special about rdtsc. We would have to see the code to understand the difference. For your example, the second rdrand instruction is removed by the common-subexpression-elimination pass. By default gcc assumes that an asm instruction reads nothing other than its inputs and changes only its outputs. By that reasoning, your second rdrand instruction will produce exactly the same result as your first one, so there is no need for it, so gcc eliminates it. The volatile qualifier tells gcc that the asm instruction does something which is not explicitly expressed in the inputs and outputs. Ian