OSDN Git Service

Add the SCCP regression tests for APInt expressions. These test cases
authorReid Spencer <rspencer@reidspencer.com>
Fri, 13 Apr 2007 22:33:10 +0000 (22:33 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Fri, 13 Apr 2007 22:33:10 +0000 (22:33 +0000)
turned up some regressions that have since been fixed. We don't want to
loose the regression tests.

Test cases by Guoling Han.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35974 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
test/Transforms/SCCP/apint-array.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-basictest.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-basictest2.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-basictest3.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-basictest4.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-bigarray.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-bigint.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-bigint2.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-ipsccp1.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-ipsccp2.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-ipsccp3.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-ipsccp4.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-load.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-phi.ll [new file with mode: 0644]
test/Transforms/SCCP/apint-select.ll [new file with mode: 0644]

diff --git a/test/Transforms/SCCP/apint-array.ll b/test/Transforms/SCCP/apint-array.ll
new file mode 100644 (file)
index 0000000..b9fe68c
--- /dev/null
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | grep 'ret i101 12'
+
+@Y = constant [6 x i101] [ i101 12, i101 123456789000000, i101 -12,i101 
+-123456789000000, i101 0,i101 9123456789000000]
+
+define i101 @array()
+{
+Head:
+   %A = getelementptr [6 x i101]* @Y, i32 0, i32 1
+
+   %B = load i101* %A
+   %C = icmp sge i101 %B, 1
+   br i1 %C, label %True, label %False
+True:
+   %D = and i101 %B, 1
+   %E = trunc i101 %D to i32
+   %F = getelementptr [6 x i101]* @Y, i32 0, i32 %E
+   %G = load i101* %F
+   br label %False
+False:
+   %H = phi i101 [%G, %True], [-1, %Head]
+   ret i101 %H
+}
diff --git a/test/Transforms/SCCP/apint-basictest.ll b/test/Transforms/SCCP/apint-basictest.ll
new file mode 100644 (file)
index 0000000..eaffc1d
--- /dev/null
@@ -0,0 +1,17 @@
+; This is a basic sanity check for constant propogation.  The add instruction 
+; should be eliminated.
+
+; RUN: llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep add
+
+define i128 @test(i1 %B) {
+       br i1 %B, label %BB1, label %BB2
+BB1:
+       %Val = add i128 0, 1
+       br label %BB3
+BB2:
+       br label %BB3
+BB3:
+       %Ret = phi i128 [%Val, %BB1], [2, %BB2]
+       ret i128 %Ret
+}
diff --git a/test/Transforms/SCCP/apint-basictest2.ll b/test/Transforms/SCCP/apint-basictest2.ll
new file mode 100644 (file)
index 0000000..7b6890b
--- /dev/null
@@ -0,0 +1,18 @@
+; This is a basic sanity check for constant propogation.  The add instruction 
+; and phi instruction should be eliminated.
+
+; RUN: llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep phi
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep add
+
+define i128 @test(i1 %B) {
+       br i1 %B, label %BB1, label %BB2
+BB1:
+       %Val = add i128 0, 1
+       br label %BB3
+BB2:
+       br label %BB3
+BB3:
+       %Ret = phi i128 [%Val, %BB1], [1, %BB2]
+       ret i128 %Ret
+}
diff --git a/test/Transforms/SCCP/apint-basictest3.ll b/test/Transforms/SCCP/apint-basictest3.ll
new file mode 100644 (file)
index 0000000..144f646
--- /dev/null
@@ -0,0 +1,24 @@
+; This is a basic sanity check for constant propogation.  It tests the basic 
+; arithmatic operations.
+
+
+; RUN: llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep mul
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep umod
+
+define i128 @test(i1 %B) {
+       br i1 %B, label %BB1, label %BB2
+BB1:
+       %t1 = add i128 0, 1
+        %t2 = sub i128 0, %t1
+        %t3 = mul i128 %t2, -1
+       br label %BB3
+BB2:
+        %f1 = udiv i128 -1, 1
+        %f2 = add i128 %f1, 1
+        %f3 = umod i128 %f2, 2121
+       br label %BB3
+BB3:
+       %Ret = phi i128 [%t3, %BB1], [%f3, %BB2]
+       ret i128 %Ret
+}
diff --git a/test/Transforms/SCCP/apint-basictest4.ll b/test/Transforms/SCCP/apint-basictest4.ll
new file mode 100644 (file)
index 0000000..e6139c5
--- /dev/null
@@ -0,0 +1,26 @@
+; This is a basic sanity check for constant propogation.  It tests the basic 
+; logic operations.
+
+
+; RUN: llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep and
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep trunc
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | grep "ret i100 -1"
+
+define i100 @test(i133 %A) {
+        %B = and i133 0, %A
+        %C = icmp sgt i133 %B, 0
+       br i1 %C, label %BB1, label %BB2
+BB1:
+        %t3 = xor i133 %B, -1
+        %t4 = trunc i133 %t3 to i100
+       br label %BB3
+BB2:
+        %f1 = or i133 -1, %A
+        %f2 = lshr i133 %f1, 33
+        %f3 = trunc i133 %f2 to i100
+       br label %BB3
+BB3:
+       %Ret = phi i100 [%t4, %BB1], [%f3, %BB2]
+       ret i100 %Ret
+}
diff --git a/test/Transforms/SCCP/apint-bigarray.ll b/test/Transforms/SCCP/apint-bigarray.ll
new file mode 100644 (file)
index 0000000..b7c6d99
--- /dev/null
@@ -0,0 +1,24 @@
+; RUN: llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep '%X'
+
+@G =  global [1000000 x i10000] zeroinitializer
+
+define internal i10000* @test(i10000 %Arg) {
+       %X = getelementptr [1000000 x i10000]* @G, i32 0, i32 999
+        store i10000 %Arg, i10000* %X
+       ret i10000* %X
+}
+
+define i10000 @caller()
+{
+        %Y = call i10000* @test(i10000 -1)
+        %Z = load i10000* %Y
+        ret i10000 %Z 
+}
+
+define i10000 @caller2()
+{
+        %Y = call i10000* @test(i10000 1)
+        %Z = load i10000* %Y
+        ret i10000 %Z 
+}
diff --git a/test/Transforms/SCCP/apint-bigint.ll b/test/Transforms/SCCP/apint-bigint.ll
new file mode 100644 (file)
index 0000000..163138c
--- /dev/null
@@ -0,0 +1,10 @@
+; RUN:  llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN:  llvm-as < %s | opt -sccp | llvm-dis | not grep xor
+
+define i11129 @test1() {
+        %B = shl i11129 1, 11128 
+        %C = sub i11129 %B, 1
+        %D = xor i11129 %B, %C
+        
+       ret i11129 %D
+}
diff --git a/test/Transforms/SCCP/apint-bigint2.ll b/test/Transforms/SCCP/apint-bigint2.ll
new file mode 100644 (file)
index 0000000..73d3b54
--- /dev/null
@@ -0,0 +1,19 @@
+; RUN:  llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN:  llvm-as < %s | opt -sccp | llvm-dis | not grep load
+
+@Y = constant [6 x i101] [ i101 12, i101 123456789000000, i101 -12,
+                           i101 -123456789000000, i101 0,i101 9123456789000000]
+
+define i101 @array()
+{
+Head:
+   %A = getelementptr [6 x i101]* @Y, i32 0, i32 1
+   %B = load i101* %A
+   %D = and i101 %B, 1
+   %DD = or i101 %D, 1
+   %E = trunc i101 %DD to i32
+   %F = getelementptr [6 x i101]* @Y, i32 0, i32 %E
+   %G = load i101* %F
+   ret i101 %G
+}
diff --git a/test/Transforms/SCCP/apint-ipsccp1.ll b/test/Transforms/SCCP/apint-ipsccp1.ll
new file mode 100644 (file)
index 0000000..348725e
--- /dev/null
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | grep -v 'ret i512 undef' | grep 'ret i8 2'
+
+define internal i512 @test(i1 %B) {
+       br i1 %B, label %BB1, label %BB2
+BB1:
+       %Val = add i512 0, 1
+       br label %BB3
+BB2:
+       br label %BB3
+BB3:
+       %Ret = phi i512 [%Val, %BB1], [2, %BB2]
+       ret i512 %Ret
+}
+
+define i8 @caller()
+{
+    %t1 = and i2 2, 1
+    %t11 = trunc i2 %t1 to i1
+    %t2 = call i512 @test(i1 %t11)
+    %t3 = trunc i512 %t2 to i8
+    ret i8 %t3
+}
+
diff --git a/test/Transforms/SCCP/apint-ipsccp2.ll b/test/Transforms/SCCP/apint-ipsccp2.ll
new file mode 100644 (file)
index 0000000..77fb696
--- /dev/null
@@ -0,0 +1,21 @@
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | grep -v 'ret i101 0' | \
+; RUN:    grep -v 'ret i101 undef' | not grep ret
+
+
+
+define internal i101 @bar(i101 %A) {
+       %x = icmp eq i101 %A, 0
+       br i1 %x, label %T, label %F
+T:
+       %B = call i101 @bar(i101 0)
+       ret i101 0
+F:      ; unreachable
+       %C = call i101 @bar(i101 1)
+       ret i101 %C
+}
+
+define i101 @foo() {
+       %X = call i101 @bar(i101 0)
+       ret i101 %X
+}
diff --git a/test/Transforms/SCCP/apint-ipsccp3.ll b/test/Transforms/SCCP/apint-ipsccp3.ll
new file mode 100644 (file)
index 0000000..eef5fa8
--- /dev/null
@@ -0,0 +1,24 @@
+; RUN:  llvm-as < %s | opt -ipsccp | llvm-dis -o /dev/null -f &&
+; RUN:  llvm-as < %s | opt -ipsccp | llvm-dis | not grep global
+
+@G = internal global i66 undef
+
+
+
+define void @foo() {
+       %X = load i66* @G
+       store i66 %X, i66* @G
+       ret void
+}
+
+define i66 @bar() {
+       %V = load i66* @G
+       %C = icmp eq i66 %V, 17
+       br i1 %C, label %T, label %F
+T:
+       store i66 17, i66* @G
+       ret i66 %V
+F:
+       store i66 123, i66* @G
+       ret i66 0
+}
diff --git a/test/Transforms/SCCP/apint-ipsccp4.ll b/test/Transforms/SCCP/apint-ipsccp4.ll
new file mode 100644 (file)
index 0000000..67d99e4
--- /dev/null
@@ -0,0 +1,51 @@
+; This test makes sure that these instructions are properly constant propagated.
+;
+
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | not grep load
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | not grep add
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | not grep phi
+
+
+@Y = constant [2 x { i212, float }] [ { i212, float } { i212 12, float 1.0 }, 
+                                     { i212, float } { i212 37, float 2.0 } ]
+
+define internal float @test2() {
+       %A = getelementptr [2 x { i212, float}]* @Y, i32 0, i32 1, i32 1
+       %B = load float* %A
+       ret float %B
+}
+
+define internal float  @test3() {
+       %A = getelementptr [2 x { i212, float}]* @Y, i32 0, i32 0, i32 1
+       %B = load float* %A
+       ret float %B
+}
+
+define internal float @test()
+{
+   %A = call float @test2()
+   %B = call float @test3()
+
+   %E = fdiv float %B, %A
+   ret float %E
+}
+
+define float @All()
+{
+  %A = call float @test()
+  %B = fcmp oge float %A, 1.0
+  br i1 %B, label %T, label %F
+T:
+  %C = add float %A, 1.0
+  br label %exit
+F:
+  %D = add float %A, 2.0
+  br label %exit
+exit:
+  %E = phi float [%C, %T], [%D, %F]
+  ret float %E
+}
+
+
+
diff --git a/test/Transforms/SCCP/apint-load.ll b/test/Transforms/SCCP/apint-load.ll
new file mode 100644 (file)
index 0000000..b943236
--- /dev/null
@@ -0,0 +1,38 @@
+; This test makes sure that these instructions are properly constant propagated.
+;
+
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | not grep load
+; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | not grep fdiv
+
+@X = constant i212 42
+@Y = constant [2 x { i212, float }] [ { i212, float } { i212 12, float 1.0 }, 
+                                     { i212, float } { i212 37, float 1.2312 } ]
+define i212 @test1() {
+       %B = load i212* @X
+       ret i212 %B
+}
+
+define internal float @test2() {
+       %A = getelementptr [2 x { i212, float}]* @Y, i32 0, i32 1, i32 1
+       %B = load float* %A
+       ret float %B
+}
+
+define internal i212 @test3() {
+       %A = getelementptr [2 x { i212, float}]* @Y, i32 0, i32 0, i32 0
+       %B = load i212* %A
+       ret i212 %B
+}
+
+define float @All()
+{
+   %A = call float @test2()
+   %B = call i212 @test3()
+   %C = mul i212 %B, -1234567
+   %D = sitofp i212 %C to float
+   %E = fdiv float %A, %D
+   ret float %E
+}
+
+
diff --git a/test/Transforms/SCCP/apint-phi.ll b/test/Transforms/SCCP/apint-phi.ll
new file mode 100644 (file)
index 0000000..899d8a9
--- /dev/null
@@ -0,0 +1,20 @@
+; RUN: llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN: llvm-as < %s | opt -sccp | llvm-dis | not grep phi
+
+define i999 @test(i999%A, i1 %c) {
+bb1:
+       br label %BB2
+BB2:
+       %V = phi i999 [2, %bb1], [%A, %BB4]
+       br label %BB3
+
+BB3:
+        %E = trunc i999 %V to i1
+        %F = and i1 %E, %c
+       br i1 %F, label %BB4, label %BB5
+BB4:
+       br label %BB2
+
+BB5:
+       ret i999 %V
+}
diff --git a/test/Transforms/SCCP/apint-select.ll b/test/Transforms/SCCP/apint-select.ll
new file mode 100644 (file)
index 0000000..25c39ce
--- /dev/null
@@ -0,0 +1,22 @@
+; RUN:  llvm-as < %s | opt -sccp | llvm-dis -o /dev/null -f &&
+; RUN:  llvm-as < %s | opt -sccp | llvm-dis | not grep select
+
+@A = constant i32 10
+
+define i712 @test1() {
+        %P = getelementptr i32* @A, i32 0
+        %B = ptrtoint i32* %P to i64
+        %BB = and i64 %B, undef
+        %C = icmp sge i64 %BB, 0
+       %X = select i1 %C, i712 0, i712 1
+       ret i712 %X
+}
+
+
+
+define i712 @test2(i1 %C) {
+       %X = select i1 %C, i712 0, i712 undef
+       ret i712 %X
+}
+
+