Add a GVN-PRE basic regression test.
authorOwen Anderson <resistor@mac.com>
Tue, 12 Jun 2007 00:49:33 +0000 (00:49 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 12 Jun 2007 00:49:33 +0000 (00:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37549 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/GVNPRE/basic.ll [new file with mode: 0644]
test/Transforms/GVNPRE/dg.exp [new file with mode: 0644]

diff --git a/test/Transforms/GVNPRE/basic.ll b/test/Transforms/GVNPRE/basic.ll
new file mode 100644 (file)
index 0000000..e03231b
--- /dev/null
@@ -0,0 +1,38 @@
+; RUN: llvm-as | opt -gvnpre | llvm-dis | not grep {%t3 =}
+; RUN: llvm-as | opt -gvnpre | llvm-dis | not grep {%t9 =}
+
+define i32 @main() {
+block1:
+       %t1 = bitcast i32 0 to i32              ; <i32> [#uses=5]
+       br label %block2
+
+block2:                ; preds = %block6, %block1
+       %t2 = phi i32 [ %t1, %block1 ], [ %t3, %block6 ]                ; <i32> [#uses=3]
+       %t3 = add i32 %t2, 1            ; <i32> [#uses=5]
+       br i1 false, label %block3, label %block7
+
+block3:                ; preds = %block2
+       br i1 true, label %block4, label %block5
+
+block4:                ; preds = %block3
+       %t4 = add i32 %t2, %t3          ; <i32> [#uses=1]
+       %t5 = bitcast i32 %t4 to i32            ; <i32> [#uses=1]
+       %t6 = add i32 %t1, %t5          ; <i32> [#uses=0]
+       br label %block6
+
+block5:                ; preds = %block3
+       %t7 = add i32 %t3, 1            ; <i32> [#uses=1]
+       br label %block6
+
+block6:                ; preds = %block5, %block4
+       %t8 = phi i32 [ %t1, %block4 ], [ %t7, %block5 ]                ; <i32> [#uses=1]
+       %t9 = add i32 %t2, %t3          ; <i32> [#uses=2]
+       %t10 = add i32 %t9, %t8         ; <i32> [#uses=0]
+       %t11 = bitcast i32 12 to i32            ; <i32> [#uses=1]
+       %t12 = add i32 %t9, %t11                ; <i32> [#uses=1]
+       %t13 = add i32 %t12, %t3                ; <i32> [#uses=0]
+       br label %block2
+
+block7:                ; preds = %block2
+       ret i32 %t1
+}
diff --git a/test/Transforms/GVNPRE/dg.exp b/test/Transforms/GVNPRE/dg.exp
new file mode 100644 (file)
index 0000000..879685c
--- /dev/null
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]]