llvm.org GIT mirror llvm / 2910f68
Add a testcase for my recent InstCombine fix, written by Nicholas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45386 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 11 years ago
1 changed file(s) with 89 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as < %s | opt -mem2reg -instcombine | llvm-dis | grep "ret i32 1" | count 8
1
2 define i32 @test1() {
3 entry:
4 %z = alloca i32
5 store i32 0, i32* %z
6 %tmp = load i32* %z
7 %sub = sub i32 %tmp, 1
8 %cmp = icmp ule i32 %sub, 0
9 %retval = select i1 %cmp, i32 0, i32 1
10 ret i32 %retval
11 }
12
13 define i32 @test2() {
14 entry:
15 %z = alloca i32
16 store i32 0, i32* %z
17 %tmp = load i32* %z
18 %sub = sub i32 %tmp, 1
19 %cmp = icmp ugt i32 %sub, 0
20 %retval = select i1 %cmp, i32 1, i32 0
21 ret i32 %retval
22 }
23
24 define i32 @test3() {
25 entry:
26 %z = alloca i32
27 store i32 0, i32* %z
28 %tmp = load i32* %z
29 %sub = sub i32 %tmp, 1
30 %cmp = icmp slt i32 %sub, 0
31 %retval = select i1 %cmp, i32 1, i32 0
32 ret i32 %retval
33 }
34
35 define i32 @test4() {
36 entry:
37 %z = alloca i32
38 store i32 0, i32* %z
39 %tmp = load i32* %z
40 %sub = sub i32 %tmp, 1
41 %cmp = icmp sle i32 %sub, 0
42 %retval = select i1 %cmp, i32 1, i32 0
43 ret i32 %retval
44 }
45
46 define i32 @test5() {
47 entry:
48 %z = alloca i32
49 store i32 0, i32* %z
50 %tmp = load i32* %z
51 %sub = sub i32 %tmp, 1
52 %cmp = icmp sge i32 %sub, 0
53 %retval = select i1 %cmp, i32 0, i32 1
54 ret i32 %retval
55 }
56
57 define i32 @test6() {
58 entry:
59 %z = alloca i32
60 store i32 0, i32* %z
61 %tmp = load i32* %z
62 %sub = sub i32 %tmp, 1
63 %cmp = icmp sgt i32 %sub, 0
64 %retval = select i1 %cmp, i32 0, i32 1
65 ret i32 %retval
66 }
67
68 define i32 @test7() {
69 entry:
70 %z = alloca i32
71 store i32 0, i32* %z
72 %tmp = load i32* %z
73 %sub = sub i32 %tmp, 1
74 %cmp = icmp eq i32 %sub, 0
75 %retval = select i1 %cmp, i32 0, i32 1
76 ret i32 %retval
77 }
78
79 define i32 @test8() {
80 entry:
81 %z = alloca i32
82 store i32 0, i32* %z
83 %tmp = load i32* %z
84 %sub = sub i32 %tmp, 1
85 %cmp = icmp ne i32 %sub, 0
86 %retval = select i1 %cmp, i32 1, i32 0
87 ret i32 %retval
88 }