summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/IndVarSimplify
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify')
-rw-r--r--llvm/test/Transforms/IndVarSimplify/constant-fold-1.ll39
-rw-r--r--llvm/test/Transforms/IndVarSimplify/replace-iv-with-loop-invariant.ll88
2 files changed, 88 insertions, 39 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/constant-fold-1.ll b/llvm/test/Transforms/IndVarSimplify/constant-fold-1.ll
deleted file mode 100644
index a1ab41d0130..00000000000
--- a/llvm/test/Transforms/IndVarSimplify/constant-fold-1.ll
+++ /dev/null
@@ -1,39 +0,0 @@
-; RUN: opt < %s -indvars -S | FileCheck %s
-
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-define void @test(i64* %arg) unnamed_addr align 2 {
-bb:
- switch i64 undef, label %bb1 [
- ]
-
-bb1: ; preds = %bb
- br label %bb2
-
-bb2: ; preds = %bb6, %bb1
- %tmp = phi i64* [%arg, %bb1 ], [ %tmp7, %bb6 ]
- switch i2 undef, label %bb6 [
- i2 1, label %bb5
- i2 -2, label %bb3
- i2 -1, label %bb3
- ]
-
-bb3: ; preds = %bb2, %bb2
- %tmp4 = call fastcc i32* @wobble(i64* nonnull %tmp, i32* null)
- %tmp5 = load i32, i32* %tmp4 , align 8
- br label %bb6
-
-bb5: ; preds = %bb2
- unreachable
-
-bb6: ; preds = %bb3, %bb2
- %tmp7 = load i64*, i64** undef, align 8
- br label %bb2
-}
-
-declare i32* @wobble(i64*, i32* returned)
-
-; Should not fail when SCEV is fold to ConstantPointerNull
-; CHECK-LABEL: void @test
-; CHECK: load i32, i32* %{{[a-zA-Z$._0-9]+}}
diff --git a/llvm/test/Transforms/IndVarSimplify/replace-iv-with-loop-invariant.ll b/llvm/test/Transforms/IndVarSimplify/replace-iv-with-loop-invariant.ll
new file mode 100644
index 00000000000..d3d6d1ed4fa
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/replace-iv-with-loop-invariant.ll
@@ -0,0 +1,88 @@
+; RUN: opt < %s -indvars -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@G = external global i32
+
+define void @test0(i64* %arg) {
+bb:
+ br label %bb2
+
+bb2:
+ %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
+ %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* null)
+ %tmp5 = load i32, i32* %tmp4, align 8
+ %tmp7 = load i64*, i64** undef, align 8
+ br label %bb2
+}
+
+; CHECK-LABEL: void @test0
+; CHECK: load i32, i32* null
+
+define void @test1(i64* %arg) {
+bb:
+ br label %bb2
+
+bb2:
+ %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
+ %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* inttoptr (i64 4 to i32*))
+ %tmp5 = load i32, i32* %tmp4
+ %tmp7 = load i64*, i64** undef, align 8
+ br label %bb2
+}
+
+; CHECK-LABEL: void @test1
+; CHECK: load i32, i32* inttoptr (i64 4 to i32*)
+
+define void @test2(i64* %arg) {
+bb:
+ br label %bb2
+
+bb2:
+ %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
+ %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* @G)
+ %tmp5 = load i32, i32* %tmp4
+ %tmp7 = load i64*, i64** undef, align 8
+ br label %bb2
+}
+
+; CHECK-LABEL: void @test2
+; CHECK: load i32, i32* @G
+
+
+define void @test3(i64* %arg, i32* %loop.invariant) {
+bb:
+ br label %bb2
+
+bb2:
+ %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
+ %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* %loop.invariant)
+ %tmp5 = load i32, i32* %tmp4
+ %tmp7 = load i64*, i64** undef, align 8
+ br label %bb2
+}
+
+; CHECK-LABEL: void @test3
+; CHECK: load i32, i32* %loop.invariant
+
+define void @test4(i64* %arg, i32* %loop.invariant, i64 %N) {
+bb:
+ br label %bb2
+
+bb2:
+ %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
+ %mul = mul nsw i64 %N, 64
+ %ptr = getelementptr inbounds i32, i32* %loop.invariant, i64 %mul
+ %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* %ptr)
+ %tmp5 = load i32, i32* %tmp4
+ %tmp7 = load i64*, i64** undef, align 8
+ br label %bb2
+}
+
+; CHECK-LABEL: void @test4
+; CHECK: [[P:%[a-zA-Z$._0-9]+]] = getelementptr i32, i32* %loop.invariant
+; CHECK: phi
+; CHECK: load i32, i32* [[P]]
+
+declare i32* @wobble(i64*, i32* returned)
OpenPOWER on IntegriCloud