summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2017-04-19 20:19:58 +0000
committerEli Friedman <efriedma@codeaurora.org>2017-04-19 20:19:58 +0000
commite77d2b86b478872128ab31d8296840161068fd26 (patch)
tree1daf3770d58af05d7a7d722c292c8b0600876208 /llvm/test
parentb45905c5a9b4c17637e951f52a5caaf535cbdc53 (diff)
downloadbcm5719-llvm-e77d2b86b478872128ab31d8296840161068fd26.tar.gz
bcm5719-llvm-e77d2b86b478872128ab31d8296840161068fd26.zip
[SCEV] Make SCEV or modeling more aggressive.
Use haveNoCommonBitsSet to figure out whether an "or" instruction is equivalent to addition. This handles more cases than just checking for a constant on the RHS. Differential Revision: https://reviews.llvm.org/D32239 llvm-svn: 300746
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Analysis/ScalarEvolution/or-as-add.ll38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/test/Analysis/ScalarEvolution/or-as-add.ll b/llvm/test/Analysis/ScalarEvolution/or-as-add.ll
new file mode 100644
index 00000000000..ac4e65a20f2
--- /dev/null
+++ b/llvm/test/Analysis/ScalarEvolution/or-as-add.ll
@@ -0,0 +1,38 @@
+; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
+
+declare void @z(i32)
+declare void @z2(i64)
+
+define void @fun(i1 %bool, i32 %x) {
+entry:
+ br label %body
+body:
+ %i = phi i32 [ 0, %entry ], [ %i.next, %body ]
+ %bottom_zero = mul i32 %i, 2
+ %a = or i32 %bottom_zero, 1
+ call void @z(i32 %a)
+ %bool_ext = zext i1 %bool to i32
+ %b = or i32 %bool_ext, %bottom_zero
+ call void @z(i32 %b)
+ %shifted = lshr i32 %x, 31
+ %c = or i32 %shifted, %bottom_zero
+ call void @z(i32 %c)
+ %i_ext = zext i32 %i to i64
+ %d = or i64 %i_ext, 4294967296
+ call void @z2(i64 %d)
+ %i.next = add i32 %i, 1
+ %cond = icmp eq i32 %i.next, 10
+ br i1 %cond, label %exit, label %body
+exit:
+ ret void
+}
+
+; CHECK: %a = or i32 %bottom_zero, 1
+; CHECK-NEXT: --> {1,+,2}<%body>
+; CHECK: %b = or i32 %bool_ext, %bottom_zero
+; CHECK-NEXT: --> {(zext i1 %bool to i32),+,2}
+; CHECK: %c = or i32 %shifted, %bottom_zero
+; CHECK-NEXT: --> {(%x /u -2147483648),+,2}<%body>
+; CHECK: %d = or i64 %i_ext, 4294967296
+; CHECK-NEXT: --> {4294967296,+,1}<nuw><nsw><%body>
+
OpenPOWER on IntegriCloud