summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2017-07-05 13:25:58 +0000
committerDavid Green <david.green@arm.com>2017-07-05 13:25:58 +0000
commitb26a0a460ca1642c6822de9c0b85a9770a9f06bb (patch)
tree617acfed7b1767a395d6ad96df64951519504b57 /llvm/test
parent6d6c4808efc212000b7210935aed27545b714b6c (diff)
downloadbcm5719-llvm-b26a0a460ca1642c6822de9c0b85a9770a9f06bb.tar.gz
bcm5719-llvm-b26a0a460ca1642c6822de9c0b85a9770a9f06bb.zip
[IndVarSimplify] Add AShr exact flags using induction variables ranges.
This adds exact flags to AShr/LShr flags where we can statically prove it is valid using the range of induction variables. This allows further optimisations to remove extra loads. Differential Revision: https://reviews.llvm.org/D34207 llvm-svn: 307157
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/IndVarSimplify/strengthen-overflow.ll84
1 files changed, 84 insertions, 0 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/strengthen-overflow.ll b/llvm/test/Transforms/IndVarSimplify/strengthen-overflow.ll
index 2bafe96e1cc..6e0538e04d6 100644
--- a/llvm/test/Transforms/IndVarSimplify/strengthen-overflow.ll
+++ b/llvm/test/Transforms/IndVarSimplify/strengthen-overflow.ll
@@ -104,5 +104,89 @@ define i32 @test.unsigned.add.1(i32* %array, i32 %length, i32 %init) {
ret i32 42
}
+define hidden void @test.shl.exact.equal() {
+; CHECK-LABEL: @test.shl.exact.equal
+entry:
+ br label %for.body
+
+for.body:
+; CHECK-LABEL: for.body
+ %k.021 = phi i32 [ 1, %entry ], [ %inc, %for.body ]
+ %shl = shl i32 1, %k.021
+ %shr1 = ashr i32 %shl, 1
+; CHECK: %shr1 = ashr exact i32 %shl, 1
+ %shr2 = lshr i32 %shl, 1
+; CHECK: %shr2 = lshr exact i32 %shl, 1
+ %inc = add nuw nsw i32 %k.021, 1
+ %exitcond = icmp eq i32 %inc, 9
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end:
+ ret void
+}
+
+define hidden void @test.shl.exact.greater() {
+; CHECK-LABEL: @test.shl.exact.greater
+entry:
+ br label %for.body
+
+for.body:
+; CHECK-LABEL: for.body
+ %k.021 = phi i32 [ 3, %entry ], [ %inc, %for.body ]
+ %shl = shl i32 1, %k.021
+ %shr1 = ashr i32 %shl, 2
+; CHECK: %shr1 = ashr exact i32 %shl, 2
+ %shr2 = lshr i32 %shl, 2
+; CHECK: %shr2 = lshr exact i32 %shl, 2
+ %inc = add nuw nsw i32 %k.021, 1
+ %exitcond = icmp eq i32 %inc, 9
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end:
+ ret void
+}
+
+define hidden void @test.shl.exact.unbound(i32 %arg) {
+; CHECK-LABEL: @test.shl.exact.unbound
+entry:
+ br label %for.body
+
+for.body:
+; CHECK-LABEL: for.body
+ %k.021 = phi i32 [ 2, %entry ], [ %inc, %for.body ]
+ %shl = shl i32 1, %k.021
+ %shr1 = ashr i32 %shl, 2
+; CHECK: %shr1 = ashr exact i32 %shl, 2
+ %shr2 = lshr i32 %shl, 2
+; CHECK: %shr2 = lshr exact i32 %shl, 2
+ %inc = add nuw nsw i32 %k.021, 1
+ %exitcond = icmp eq i32 %inc, %arg
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end:
+ ret void
+}
+
+define hidden void @test.shl.nonexact() {
+; CHECK-LABEL: @test.shl.nonexact
+entry:
+ br label %for.body
+
+for.body:
+; CHECK-LABEL: for.body
+ %k.021 = phi i32 [ 2, %entry ], [ %inc, %for.body ]
+ %shl = shl i32 1, %k.021
+ %shr1 = ashr i32 %shl, 3
+; CHECK: %shr1 = ashr i32 %shl, 3
+ %shr2 = lshr i32 %shl, 3
+; CHECK: %shr2 = lshr i32 %shl, 3
+ %inc = add nuw nsw i32 %k.021, 1
+ %exitcond = icmp eq i32 %inc, 9
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end:
+ ret void
+}
+
!0 = !{i32 0, i32 2}
!1 = !{i32 0, i32 42}
OpenPOWER on IntegriCloud