summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-11-05 00:59:59 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-11-05 00:59:59 +0000
commitbf7550e7ecabb10e7a17e6d5067aa8c87810b46b (patch)
tree2f5168b432205c82ea2c9cecf095f9dfc2a8408b /llvm/test
parent629680e499c5df3f8965bfbc5b6100261dce0f5a (diff)
downloadbcm5719-llvm-bf7550e7ecabb10e7a17e6d5067aa8c87810b46b.tar.gz
bcm5719-llvm-bf7550e7ecabb10e7a17e6d5067aa8c87810b46b.zip
InstSimplify: Exact shifts of X by Y are X if X has the lsb set
Exact shifts may not shift out any non-zero bits. Use computeKnownBits to determine when this occurs and just return the left hand side. This fixes PR21477. llvm-svn: 221325
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstSimplify/shr-nop.ll14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/shr-nop.ll b/llvm/test/Transforms/InstSimplify/shr-nop.ll
index 86917ad8fba..b0dc8731a11 100644
--- a/llvm/test/Transforms/InstSimplify/shr-nop.ll
+++ b/llvm/test/Transforms/InstSimplify/shr-nop.ll
@@ -330,3 +330,17 @@ define i1 @exact_lshr_ne_noexactlog(i8 %a) {
%cmp = icmp ne i8 %shr, 30
ret i1 %cmp
}
+
+; CHECK-LABEL: @exact_lshr_lowbit
+; CHECK-NEXT: ret i32 7
+define i32 @exact_lshr_lowbit(i32 %shiftval) {
+ %shr = lshr exact i32 7, %shiftval
+ ret i32 %shr
+}
+
+; CHECK-LABEL: @exact_ashr_lowbit
+; CHECK-NEXT: ret i32 7
+define i32 @exact_ashr_lowbit(i32 %shiftval) {
+ %shr = ashr exact i32 7, %shiftval
+ ret i32 %shr
+}
OpenPOWER on IntegriCloud