summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorMichael Liao <michael.liao@intel.com>2013-03-28 23:38:52 +0000
committerMichael Liao <michael.liao@intel.com>2013-03-28 23:38:52 +0000
commit5fff5c7b2679da199bd566cd80c5d058c7fc3d86 (patch)
tree74d2353ead4c29fcbbdb4837f0301fe06d88c012 /llvm/test
parent4b04e66c4fd8e3b0ef37de17d7af0beb959ff349 (diff)
downloadbcm5719-llvm-5fff5c7b2679da199bd566cd80c5d058c7fc3d86.tar.gz
bcm5719-llvm-5fff5c7b2679da199bd566cd80c5d058c7fc3d86.zip
Enhance boolean simplification to handle 16-/64-bit RDRAND
- RDRAND always clears the destination value when a random value is not available (i.e. CF == 0). This value is truncated or zero-extended as the false boolean value to be returned. Boolean simplification needs to skip this 'zext' or 'trunc' node. llvm-svn: 178312
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/bool-simplify.ll36
1 files changed, 34 insertions, 2 deletions
diff --git a/llvm/test/CodeGen/X86/bool-simplify.ll b/llvm/test/CodeGen/X86/bool-simplify.ll
index 09eb5d1038f..6d8e7fbe45e 100644
--- a/llvm/test/CodeGen/X86/bool-simplify.ll
+++ b/llvm/test/CodeGen/X86/bool-simplify.ll
@@ -39,7 +39,22 @@ define i32 @bax(<2 x i64> %c) {
; CHECK: ret
}
-define i32 @rnd(i32 %arg) nounwind uwtable {
+define i16 @rnd16(i16 %arg) nounwind uwtable {
+ %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
+; CHECK: rnd16
+; CHECK: rdrand
+; CHECK: cmov
+; CHECK-NOT: cmov
+; CHECK: ret
+}
+
+define i32 @rnd32(i32 %arg) nounwind uwtable {
%1 = tail call { i32, i32 } @llvm.x86.rdrand.32() nounwind
%2 = extractvalue { i32, i32 } %1, 0
%3 = extractvalue { i32, i32 } %1, 1
@@ -47,7 +62,22 @@ define i32 @rnd(i32 %arg) nounwind uwtable {
%5 = select i1 %4, i32 0, i32 %arg
%6 = add i32 %5, %2
ret i32 %6
-; CHECK: rnd
+; CHECK: rnd32
+; CHECK: rdrand
+; CHECK: cmov
+; CHECK-NOT: cmov
+; CHECK: ret
+}
+
+define i64 @rnd64(i64 %arg) nounwind uwtable {
+ %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
+; CHECK: rnd64
; CHECK: rdrand
; CHECK: cmov
; CHECK-NOT: cmov
@@ -55,4 +85,6 @@ define i32 @rnd(i32 %arg) nounwind uwtable {
}
declare i32 @llvm.x86.sse41.ptestz(<2 x i64>, <2 x i64>) nounwind readnone
+declare { i16, i32 } @llvm.x86.rdrand.16() nounwind
declare { i32, i32 } @llvm.x86.rdrand.32() nounwind
+declare { i64, i32 } @llvm.x86.rdrand.64() nounwind
OpenPOWER on IntegriCloud