2017-07-03 23:27:19 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1,-avx,+rdrnd,+rdseed | FileCheck %s
|
2012-08-11 03:58:13 +08:00
|
|
|
|
|
|
|
define i32 @foo(<2 x i64> %c, i32 %a, i32 %b) {
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-LABEL: foo:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: ptest %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: cmovnel %esi, %edi
|
|
|
|
; CHECK-NEXT: movl %edi, %eax
|
|
|
|
; CHECK-NEXT: retq
|
2012-08-11 03:58:13 +08:00
|
|
|
%t1 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c)
|
|
|
|
%t2 = icmp ne i32 %t1, 0
|
|
|
|
%t3 = select i1 %t2, i32 %a, i32 %b
|
|
|
|
ret i32 %t3
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @bar(<2 x i64> %c) {
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-LABEL: bar:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: ptest %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: jne .LBB1_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK-NEXT: # %bb.1: # %if-true-block
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
; CHECK-NEXT: .LBB1_2: # %endif-block
|
|
|
|
; CHECK-NEXT: movl $1, %eax
|
|
|
|
; CHECK-NEXT: retq
|
2012-08-11 03:58:13 +08:00
|
|
|
entry:
|
|
|
|
%0 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c)
|
|
|
|
%1 = icmp ne i32 %0, 0
|
|
|
|
br i1 %1, label %if-true-block, label %endif-block
|
2017-07-03 23:27:19 +08:00
|
|
|
if-true-block:
|
2012-08-11 03:58:13 +08:00
|
|
|
ret i32 0
|
2017-07-03 23:27:19 +08:00
|
|
|
endif-block:
|
2012-08-11 03:58:13 +08:00
|
|
|
ret i32 1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @bax(<2 x i64> %c) {
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-LABEL: bax:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: ptest %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: sete %al
|
|
|
|
; CHECK-NEXT: retq
|
2012-08-11 03:58:13 +08:00
|
|
|
%t1 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c)
|
|
|
|
%t2 = icmp eq i32 %t1, 1
|
|
|
|
%t3 = zext i1 %t2 to i32
|
|
|
|
ret i32 %t3
|
|
|
|
}
|
|
|
|
|
2017-07-03 23:27:19 +08:00
|
|
|
define i16 @rnd16(i16 %arg) nounwind {
|
|
|
|
; CHECK-LABEL: rnd16:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: rdrandw %cx
|
2018-02-21 01:41:00 +08:00
|
|
|
; CHECK-NEXT: cmovbl %edi, %eax
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: addl %ecx, %eax
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: retq
|
2013-03-29 07:38:52 +08:00
|
|
|
%1 = tail call { i16, i32 } @llvm.x86.rdrand.16() nounwind
|
|
|
|
%2 = extractvalue { i16, i32 } %1, 0
|
|
|
|
%3 = extractvalue { i16, i32 } %1, 1
|
|
|
|
%4 = icmp eq i32 %3, 0
|
|
|
|
%5 = select i1 %4, i16 0, i16 %arg
|
|
|
|
%6 = add i16 %5, %2
|
|
|
|
ret i16 %6
|
|
|
|
}
|
|
|
|
|
2017-07-03 23:27:19 +08:00
|
|
|
define i32 @rnd32(i32 %arg) nounwind {
|
|
|
|
; CHECK-LABEL: rnd32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: rdrandl %ecx
|
|
|
|
; CHECK-NEXT: cmovbl %edi, %eax
|
|
|
|
; CHECK-NEXT: addl %ecx, %eax
|
|
|
|
; CHECK-NEXT: retq
|
2012-09-11 00:36:16 +08:00
|
|
|
%1 = tail call { i32, i32 } @llvm.x86.rdrand.32() nounwind
|
|
|
|
%2 = extractvalue { i32, i32 } %1, 0
|
|
|
|
%3 = extractvalue { i32, i32 } %1, 1
|
|
|
|
%4 = icmp eq i32 %3, 0
|
|
|
|
%5 = select i1 %4, i32 0, i32 %arg
|
|
|
|
%6 = add i32 %5, %2
|
|
|
|
ret i32 %6
|
2013-03-29 07:38:52 +08:00
|
|
|
}
|
|
|
|
|
2017-07-03 23:27:19 +08:00
|
|
|
define i64 @rnd64(i64 %arg) nounwind {
|
|
|
|
; CHECK-LABEL: rnd64:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: rdrandq %rcx
|
|
|
|
; CHECK-NEXT: cmovbq %rdi, %rax
|
|
|
|
; CHECK-NEXT: addq %rcx, %rax
|
|
|
|
; CHECK-NEXT: retq
|
2013-03-29 07:38:52 +08:00
|
|
|
%1 = tail call { i64, i32 } @llvm.x86.rdrand.64() nounwind
|
|
|
|
%2 = extractvalue { i64, i32 } %1, 0
|
|
|
|
%3 = extractvalue { i64, i32 } %1, 1
|
|
|
|
%4 = icmp eq i32 %3, 0
|
|
|
|
%5 = select i1 %4, i64 0, i64 %arg
|
|
|
|
%6 = add i64 %5, %2
|
|
|
|
ret i64 %6
|
2012-09-11 00:36:16 +08:00
|
|
|
}
|
|
|
|
|
2017-07-03 23:27:19 +08:00
|
|
|
define i16 @seed16(i16 %arg) nounwind {
|
|
|
|
; CHECK-LABEL: seed16:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: rdseedw %cx
|
2018-02-21 01:41:00 +08:00
|
|
|
; CHECK-NEXT: cmovbl %edi, %eax
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: addl %ecx, %eax
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: retq
|
2013-03-29 07:41:26 +08:00
|
|
|
%1 = tail call { i16, i32 } @llvm.x86.rdseed.16() nounwind
|
|
|
|
%2 = extractvalue { i16, i32 } %1, 0
|
|
|
|
%3 = extractvalue { i16, i32 } %1, 1
|
|
|
|
%4 = icmp eq i32 %3, 0
|
|
|
|
%5 = select i1 %4, i16 0, i16 %arg
|
|
|
|
%6 = add i16 %5, %2
|
|
|
|
ret i16 %6
|
|
|
|
}
|
|
|
|
|
2017-07-03 23:27:19 +08:00
|
|
|
define i32 @seed32(i32 %arg) nounwind {
|
|
|
|
; CHECK-LABEL: seed32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: rdseedl %ecx
|
|
|
|
; CHECK-NEXT: cmovbl %edi, %eax
|
|
|
|
; CHECK-NEXT: addl %ecx, %eax
|
|
|
|
; CHECK-NEXT: retq
|
2013-03-29 07:41:26 +08:00
|
|
|
%1 = tail call { i32, i32 } @llvm.x86.rdseed.32() nounwind
|
|
|
|
%2 = extractvalue { i32, i32 } %1, 0
|
|
|
|
%3 = extractvalue { i32, i32 } %1, 1
|
|
|
|
%4 = icmp eq i32 %3, 0
|
|
|
|
%5 = select i1 %4, i32 0, i32 %arg
|
|
|
|
%6 = add i32 %5, %2
|
|
|
|
ret i32 %6
|
|
|
|
}
|
|
|
|
|
2017-07-03 23:27:19 +08:00
|
|
|
define i64 @seed64(i64 %arg) nounwind {
|
|
|
|
; CHECK-LABEL: seed64:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-07-03 23:27:19 +08:00
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: rdseedq %rcx
|
|
|
|
; CHECK-NEXT: cmovbq %rdi, %rax
|
|
|
|
; CHECK-NEXT: addq %rcx, %rax
|
|
|
|
; CHECK-NEXT: retq
|
2013-03-29 07:41:26 +08:00
|
|
|
%1 = tail call { i64, i32 } @llvm.x86.rdseed.64() nounwind
|
|
|
|
%2 = extractvalue { i64, i32 } %1, 0
|
|
|
|
%3 = extractvalue { i64, i32 } %1, 1
|
|
|
|
%4 = icmp eq i32 %3, 0
|
|
|
|
%5 = select i1 %4, i64 0, i64 %arg
|
|
|
|
%6 = add i64 %5, %2
|
|
|
|
ret i64 %6
|
|
|
|
}
|
|
|
|
|
2012-08-11 03:58:13 +08:00
|
|
|
declare i32 @llvm.x86.sse41.ptestz(<2 x i64>, <2 x i64>) nounwind readnone
|
2013-03-29 07:38:52 +08:00
|
|
|
declare { i16, i32 } @llvm.x86.rdrand.16() nounwind
|
2012-09-11 00:36:16 +08:00
|
|
|
declare { i32, i32 } @llvm.x86.rdrand.32() nounwind
|
2013-03-29 07:38:52 +08:00
|
|
|
declare { i64, i32 } @llvm.x86.rdrand.64() nounwind
|
2013-03-29 07:41:26 +08:00
|
|
|
declare { i16, i32 } @llvm.x86.rdseed.16() nounwind
|
|
|
|
declare { i32, i32 } @llvm.x86.rdseed.32() nounwind
|
|
|
|
declare { i64, i32 } @llvm.x86.rdseed.64() nounwind
|