1 ; RUN: llc < %s -march=x86-64 -mcpu=core-avx-i -mattr=+rdseed | FileCheck %s
3 declare {i16, i32} @llvm.x86.rdseed.16()
4 declare {i32, i32} @llvm.x86.rdseed.32()
5 declare {i64, i32} @llvm.x86.rdseed.64()
7 define i32 @_rdseed16_step(i16* %random_val) {
8 %call = call {i16, i32} @llvm.x86.rdseed.16()
9 %randval = extractvalue {i16, i32} %call, 0
10 store i16 %randval, i16* %random_val
11 %isvalid = extractvalue {i16, i32} %call, 1
13 ; CHECK: _rdseed16_step:
15 ; CHECK: movzwl %ax, %ecx
16 ; CHECK: movl $1, %eax
17 ; CHECK: cmovael %ecx, %eax
18 ; CHECK: movw %cx, (%r[[A0:di|cx]])
22 define i32 @_rdseed32_step(i32* %random_val) {
23 %call = call {i32, i32} @llvm.x86.rdseed.32()
24 %randval = extractvalue {i32, i32} %call, 0
25 store i32 %randval, i32* %random_val
26 %isvalid = extractvalue {i32, i32} %call, 1
28 ; CHECK: _rdseed32_step:
29 ; CHECK: rdseedl %e[[T0:[a-z]+]]
30 ; CHECK: movl $1, %eax
31 ; CHECK: cmovael %e[[T0]], %eax
32 ; CHECK: movl %e[[T0]], (%r[[A0]])
36 define i32 @_rdseed64_step(i64* %random_val) {
37 %call = call {i64, i32} @llvm.x86.rdseed.64()
38 %randval = extractvalue {i64, i32} %call, 0
39 store i64 %randval, i64* %random_val
40 %isvalid = extractvalue {i64, i32} %call, 1
42 ; CHECK: _rdseed64_step:
43 ; CHECK: rdseedq %r[[T1:[a-z]+]]
44 ; CHECK: movl $1, %eax
45 ; CHECK: cmovael %e[[T1]], %eax
46 ; CHECK: movq %r[[T1]], (%r[[A0]])