summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstSimplify/compare.ll
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-08-27 18:03:46 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-08-27 18:03:46 +0000
commitd6d1671c1eb241939b6d92687420a3f7ed56839f (patch)
tree1691a7a66bc0b9372d3bb4ccb4919a3a9ab45760 /llvm/test/Transforms/InstSimplify/compare.ll
parent74a46c24f3be4a8a758d9c9d3d838b8851cb010d (diff)
downloadbcm5719-llvm-d6d1671c1eb241939b6d92687420a3f7ed56839f.tar.gz
bcm5719-llvm-d6d1671c1eb241939b6d92687420a3f7ed56839f.zip
InstSimplify: Compute comparison ranges for left shift instructions
'shl nuw CI, x' produces [CI, CI << CLZ(CI)] 'shl nsw CI, x' produces [CI << CLO(CI)-1, CI] if CI is negative 'shl nsw CI, x' produces [CI, CI << CLZ(CI)-1] if CI is non-negative llvm-svn: 216570
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/compare.ll')
-rw-r--r--llvm/test/Transforms/InstSimplify/compare.ll27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll
index 27fe1bead23..764d76690e6 100644
--- a/llvm/test/Transforms/InstSimplify/compare.ll
+++ b/llvm/test/Transforms/InstSimplify/compare.ll
@@ -982,3 +982,30 @@ define i1 @icmp_known_bits(i4 %x, i4 %y) {
; CHECK-LABEL: @icmp_known_bits
; CHECK-NEXT: ret i1 false
}
+
+define i1 @icmp_shl_nuw_1(i64 %a) {
+ %shl = shl nuw i64 1, %a
+ %cmp = icmp ne i64 %shl, 0
+ ret i1 %cmp
+
+; CHECK-LABEL: @icmp_shl_nuw_1
+; CHECK-NEXT: ret i1 true
+}
+
+define i1 @icmp_shl_nsw_neg1(i64 %a) {
+ %shl = shl nsw i64 -1, %a
+ %cmp = icmp sge i64 %shl, 3
+ ret i1 %cmp
+
+; CHECK-LABEL: @icmp_shl_nsw_neg1
+; CHECK-NEXT: ret i1 false
+}
+
+define i1 @icmp_shl_nsw_1(i64 %a) {
+ %shl = shl nsw i64 1, %a
+ %cmp = icmp sge i64 %shl, 0
+ ret i1 %cmp
+
+; CHECK-LABEL: @icmp_shl_nsw_1
+; CHECK-NEXT: ret i1 true
+}
OpenPOWER on IntegriCloud