llvm.org GIT mirror llvm / 50e8682
Remove explicit control flow through the use of the 'not' script git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6965 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
65 changed file(s) with 88 addition(s) and 312 deletion(s). Raw diff Collapse all Expand all
0 ; This testcase tests for various features the basicaa test should be able to
11 ; determine, as noted in the comments.
22
3 ; RUN: if as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | grep REMOVE
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | not grep REMOVE
74
85 %Global = external global { int }
96
11 ; disambiguating some obvious cases. All loads should be removable in
22 ; this testcase.
33
4 ; RUN: if as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | grep load
5 ; RUN: then exit 1
6 ; RUN: else exit 0
7 ; RUN: fi
4 ; RUN: as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | not grep load
85
96 %A = global int 7
107 %B = global int 8
22 ; two pointers, then the load should be hoisted, and the store sunk. Thus
33 ; the loop becomes empty and can be deleted by ADCE.
44
5 ; RUN: if as < %s | opt -basicaa -licm --adce | dis | grep Loop
6 ; RUN: then exit 1
7 ; RUN: else exit 0
8 ; RUN: fi
5 ; RUN: as < %s | opt -basicaa -licm --adce | dis | not grep Loop
96
107 %A = global int 7
118 %B = global int 8
0 ; Test that GCSE uses ds-aa to do alias analysis, which is capable of
11 ; disambiguating some cases.
22
3 ; RUN: if as < %s | opt -ds-aa -load-vn -gcse -instcombine -dce | dis | grep ELIM
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -ds-aa -load-vn -gcse -instcombine -dce | dis | not grep ELIM
74
85 %intpair = type {int*, int*}
96 implementation
0 ; This testcase ensures that redundant loads are eliminated when they should
11 ; be. All RL variables (redundant loads) should be eliminated.
22 ;
3 ; RUN: if as < %s | opt -load-vn -gcse | dis | grep %RL
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -load-vn -gcse | dis | not grep %RL
74 ;
85 int "test1"(int* %P) {
96 %A = load int* %P
33 ; Check by running globaldce, which will remove the constant if there are
44 ; no references to it!
55 ;
6 ; RUN: if as < %s | opt -globaldce | dis | grep constant
7 ; RUN: then exit 1
8 ; RUN: else exit 0
9 ; RUN: fi
6 ; RUN: as < %s | opt -globaldce | dis | grep-not constant
107 ;
118
129 %v1 = internal constant int 5
1411 implementation
1512
1613 int "createtask"()
17 begin
1814 %v1 = alloca int ;; Alloca should have one use!
1915 %reg112 = load int* %v1 ;; This load should not use the global!
2016 ret int %reg112
0 ; This test checks to make sure that constant exprs fold in some simple situations
11
2 ; RUN: if as < %s | dis | grep cast
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | dis | grep-not cast
63
74 %A = global int* cast (sbyte* null to int*) ; Cast null -> fold
85 %B = global int** cast (int** %A to int**) ; Cast to same type -> fold
44
55 ; RUN: echo "implementation internal int %foo() { ret int 7 }" | as > Output/%s.1.bc
66 ; RUN: as < %s > Output/%s.2.bc
7 ; RUN: if link Output/%s.[12].bc | dis | grep 'internal' | grep '%foo('
8 ; RUN: then exit 1
9 ; RUN: else exit 0
10 ; RUN: fi
7 ; RUN: link Output/%s.[12].bc | dis | grep 'internal' | grep-not '%foo('
118
129 implementation
1310 declare int %foo()
None ; RUN: if as < %s | opt -adce -simplifycfg | dis | grep then:
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -adce -simplifycfg | dis | not grep then:
41
52 void %dead_test8(int* %data.1, int %idx.1) {
63 entry: ; No predecessors!
0 ; This is the test case taken from Appel's book that illustrates a hard case
11 ; that SCCP gets right, and when followed by ADCE, is completely eliminated
22 ;
3 ; RUN: if as < %s | opt -sccp -adce -simplifycfg | dis | grep br
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -sccp -adce -simplifycfg | dis | not grep br
74
85 int "test function"(int %i0, int %j0) {
96 BB1:
0 ; This testcase tests for various features the basicaa test should be able to
11 ; determine, as noted in the comments.
22
3 ; RUN: if as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | grep REMOVE
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | not grep REMOVE
74
85 %Global = external global { int }
96
11 ; disambiguating some obvious cases. All loads should be removable in
22 ; this testcase.
33
4 ; RUN: if as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | grep load
5 ; RUN: then exit 1
6 ; RUN: else exit 0
7 ; RUN: fi
4 ; RUN: as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | not grep load
85
96 %A = global int 7
107 %B = global int 8
22 ; two pointers, then the load should be hoisted, and the store sunk. Thus
33 ; the loop becomes empty and can be deleted by ADCE.
44
5 ; RUN: if as < %s | opt -basicaa -licm --adce | dis | grep Loop
6 ; RUN: then exit 1
7 ; RUN: else exit 0
8 ; RUN: fi
5 ; RUN: as < %s | opt -basicaa -licm --adce | dis | not grep Loop
96
107 %A = global int 7
118 %B = global int 8
33
44 ; Fix #2: The unary not instruction now no longer exists. Change to xor.
55
6 ; RUN: if as < %s | opt -constprop | dis | grep 'int 0'
7 ; RUN: then exit 1
8 ; RUN: else exit 0
9 ; RUN: fi
6 ; RUN: as < %s | opt -constprop | dis | not grep 'int 0'
107
118 int "test1"() {
129 %R = xor int 123, -1
0 ; SetCC on boolean values was not implemented!
11
2 ; RUN: if as < %s | opt -constprop -die | dis | grep 'set'
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -constprop -die | dis | not grep 'set'
63
74 bool "test1"() {
85 %A = setle bool true, false
0 ; This is a basic sanity check for constant propogation. The add instruction
11 ; should be eliminated.
22
3 ; RUN: if as < %s | opt -constprop -die | dis | grep add
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -constprop -die | dis | not grep add
74
8 int "test"(bool %B)
9 begin
5 int %test(bool %B) {
106 br bool %B, label %BB1, label %BB2
117 BB1:
128 %Val = add int 0, 0
1612 BB3:
1713 %Ret = phi int [%Val, %BB1], [1, %BB2]
1814 ret int %Ret
19 end
15 }
0 ; Ensure constant propogation of logical instructions is working correctly.
11
2 ; RUN: if as < %s | opt -constprop -die | dis | ggrep -E 'and|or|xor'
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -constprop -die | dis | not ggrep -E 'and|or|xor'
63
74
85 int "test1"() { %R = and int 4,1234 ret int %R }
0 ; Ensure constant propogation of 'not' instructions is working correctly.
11
2 ; RUN: if as < %s | opt -constprop -die | dis | grep xor
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -constprop -die | dis | not grep xor
63
74 int "test1"() {
85 %R = xor int 4, -1
0 ; This is a basic sanity check for constant propogation. The add instruction
11 ; should be eliminated.
22
3 ; RUN: if as < %s | opt -constprop -die | dis | grep phi
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -constprop -die | dis | not grep phi
74
8 int "test"(bool %B)
9 begin
5 int %test(bool %B) {
106 BB0:
117 br bool %B, label %BB1, label %BB3
128 BB1:
1410 BB3:
1511 %Ret = phi int [1, %BB0], [1, %BB1]
1612 ret int %Ret
17 end
13 }
None ; Ensure constant propogation of remainder instructions is working correctly.
0 ; Ensure constant propagation of remainder instructions is working correctly.
11
2 ; RUN: if as < %s | opt -constprop -die | dis | grep rem
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -constprop -die | dis | not grep rem
63
7 int "test1"() {
4 int %test1() {
85 %R = rem int 4, 3
96 ret int %R
107 }
118
12 int "test2"() {
9 int %test2() {
1310 %R = rem int 123, -23
1411 ret int %R
1512 }
1613
17 float "test3"() {
14 float %test3() {
1815 %R = rem float 12.45, 123.213
1916 ret float %R
2017 }
2118
22 double "test4"() {
19 double %test4() {
2320 %R = rem double 312.20213123, 12.3333412
2421 ret double %R
2522 }
1111 ; }
1212 ; }
1313 ;
14 ; RUN: if as < %s | opt -cee -simplifycfg | dis | grep bb3
15 ; RUN: then exit 1
16 ; RUN: else exit 0
17 ; RUN: fi
14 ; RUN: as < %s | opt -cee -simplifycfg | dis | not grep bb3
1815
1916 implementation
2017 declare void %bar()
None ; RUN: if as < %s | opt -cee -constprop -instcombine -dce | dis | grep 'REMOVE'
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -cee -constprop -instcombine -dce | dis | not grep 'REMOVE'
41
52 int %test1(int %A) {
63 %cond = seteq int %A, 40
None ; RUN: if as < %s | opt -cee -simplifycfg | dis | grep 'REMOVE'
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -cee -simplifycfg | dis | not grep 'REMOVE'
41
52 implementation
63
1010 ;
1111 ; Note that this is a "feature" test, not a correctness test.
1212 ;
13 ; RUN: if as < %s | opt -cee -simplifycfg | dis | grep cond213
14 ; RUN: then exit 1
15 ; RUN: else exit 0
16 ; RUN: fi
13 ; RUN: as < %s | opt -cee -simplifycfg | dis | not grep cond213
1714 ;
1815 implementation ; Functions:
1916
0 ; a load or store of a pointer indicates that the pointer is not null.
11 ; Any succeeding uses of the pointer should get this info
22
3 ; RUN: if as < %s | opt -cee -instcombine -simplifycfg | dis | grep br
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -cee -instcombine -simplifycfg | dis | not grep br
74
85 implementation ; Functions:
96
1010 ;
1111 ; This should eliminate all BB's except BB0, BB9, BB10
1212 ;
13 ; RUN: if as < %s | opt -cee -instcombine -simplifycfg | dis | grep 'bb[2-8]'
14 ; RUN: then exit 1
15 ; RUN: else exit 0
16 ; RUN: fi
13 ; RUN: as < %s | opt -cee -instcombine -simplifycfg | dis | not grep 'bb[2-8]'
1714
1815 implementation ; Functions:
1916
None ; RUN: if as < %s | opt -deadargelim | dis | grep DEADARG
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -deadargelim | dis | not grep DEADARG
41
52 implementation
63
0 ; Test that: extern int X[] and int X[] = { 1, 2, 3, 4 } are resolved
11 ; correctly.
22 ;
3 ; RUN: if as < %s | opt -funcresolve > /dev/null
4 ; RUN: then echo "opt ok"
5 ; RUN: else exit 1 # Make sure opt doesn't abort!
6 ; RUN: fi
7 ;
8 ; RUN: if as < %s | opt -funcresolve | dis | grep external
9 ; RUN: then exit 1
10 ; RUN: else exit 0
11 ; RUN: fi
12 ;
3 ; RUN: as < %s | opt -funcresolve | dis | not grep external
134
145 %X = external global [0 x int]
156 %X = global [4 x int] [ int 1, int 2, int 3, int 4 ]
0 ; Test that: extern int X[] and int X[] = { 1, 2, 3, 4 } are resolved
11 ; correctly. This doesn't have constantexprs
22 ;
3 ; RUN: if as < %s | opt -funcresolve | dis | grep external
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -funcresolve | dis | not grep external
74 ;
85
96 %X = external global [0 x int]
None ; RUN: if as < %s | opt -funcresolve -funcresolve | dis | grep declare
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -funcresolve -funcresolve | dis | not grep declare
41
52 declare void %qsortg(sbyte*, int, int)
63
None ; RUN: if as < %s | opt -funcresolve > /dev/null
1 ; RUN: then echo "opt ok"
2 ; RUN: else exit 1 # Make sure opt doesn't abort!
3 ; RUN: fi
4 ;
5 ; RUN: if as < %s | opt -funcresolve -instcombine | dis | grep '\.\.\.'
6 ; RUN: then exit 1
7 ; RUN: else exit 0
8 ; RUN: fi
1 ; RUN: as < %s | opt -funcresolve -instcombine | dis | not grep '\.\.\.'
92
103 declare int %foo(...)
114 declare int %foo(int)
None ; RUN: if as < %s | opt -funcresolve -disable-output 2>&1 | grep WARNING
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -funcresolve -disable-output 2>&1 | not grep WARNING
1
42 %__popcount_tab = external constant [0 x ubyte]
53 %__popcount_tab = constant [4 x ubyte] c"\00\01\01\02"
64
0 ; This testcase should not cause a warning!
11
2 ; RUN: if (as < %s | opt -funcresolve -disable-output) 2>&1 | grep 'WARNING'
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: (as < %s | opt -funcresolve -disable-output) 2>&1 | not grep 'WARNING'
63
74 %X = internal global float 1.0
85 %X = internal global int 1
None ; RUN: if as < %s | opt -funcresolve | dis | grep declare
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -funcresolve | dis | not grep declare
1
42 %Table = constant int(...)* %foo
53
64 %Table2 = constant [1 x int(...)* ] [ int(...)* %foo ]
None ; RUN: if as < %s | opt -funcresolve | dis | grep declare
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -funcresolve | dis | not grep declare
41
52 declare void %test(...)
63
None ; RUN: if as < %s | opt -funcresolve -instcombine | dis | grep '\.\.\.' | grep call
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -funcresolve -instcombine | dis | grep '\.\.\.' | not grep call
41
52 declare int %foo(...)
63
0 ; This shows where the function is called with the prototype indicating a
11 ; return type exists, but it really doesn't.
2 ; RUN: if as < %s | opt -funcresolve > /dev/null
3 ; RUN: then echo "opt ok"
4 ; RUN: else exit 1 # Make sure opt doesn't abort!
5 ; RUN: fi
6 ;
7 ; RUN: if as < %s | opt -funcresolve -instcombine | dis | grep '\.\.\.' | grep call
8 ; RUN: then exit 1
9 ; RUN: else exit 0
10 ; RUN: fi
2 ; RUN: as < %s | opt -funcresolve -instcombine | dis | grep '\.\.\.' | not grep call
113
124 declare int %foo(...)
135
0 ; This shows where the function is called with the prototype indicating a
11 ; return type doesn't exists, but it really does.
22 ;
3 ; RUN: if as < %s | opt -funcresolve > /dev/null
4 ; RUN: then echo "opt ok"
5 ; RUN: else exit 1 # Make sure opt doesn't abort!
6 ; RUN: fi
7 ;
8 ; RUN: if as < %s | opt -funcresolve -instcombine | dis | grep '\.\.\.' | grep call
9 ; RUN: then exit 1
10 ; RUN: else exit 0
11 ; RUN: fi
3 ; RUN: as < %s | opt -funcresolve -instcombine | dis | grep '\.\.\.' | not grep call
124
135 declare void %foo(...)
146
0 ; This entire chain of computation should be optimized away, but
11 ; wasn't because the two multiplies were not detected as being identical.
22 ;
3 ; RUN: if as < %s | opt -gcse -instcombine -dce | dis | grep sub
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -gcse -instcombine -dce | dis | not grep sub
74
85 implementation ; Functions:
96
0 ; This testcase shows a bug where an common subexpression exists, but there
11 ; is no shared dominator block that the expression can be hoisted out to.
22 ;
3 ; RUN: if as < %s | opt -load-vn -gcse | dis | grep load
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -load-vn -gcse | dis | not grep load
74
85 int %test(int* %P) {
96 store int 5, int* %P
0 ; Make sure that functions are removed successfully if they are referred to by
11 ; a global that is dead. Make sure any globals they refer to die as well.
22
3 ; RUN: if as < %s | opt -globaldce | dis | grep foo
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -globaldce | dis | not grep foo
74
85 %b = internal global int ()* %foo ;; Unused, kills %foo
96
0 ; This testcase tests that a worklist is being used, and that globals can be
11 ; removed if they are the subject of a constexpr and ConstantPointerRef
22
3 ; RUN: if as < %s | opt -globaldce | dis | grep global
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -globaldce | dis | not grep global
74
85 %t0 = internal global [4 x sbyte] c"foo\00"
96 %t1 = internal global [4 x sbyte] c"bar\00"
None ; RUN: if as < %s | opt -globaldce | dis | grep global
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
4
0 ; RUN: as < %s | opt -globaldce | dis | not grep global
51
62 %X = uninitialized global int
73 %Y = internal global int 7
22 ; happens because preheader insertion doesn't insert a preheader for this
33 ; case... bad.
44
5 ; RUN: if as < %s | opt -licm -adce -simplifycfg | dis | grep 'br '
6 ; RUN: then exit 1
7 ; RUN: else exit 0
8 ; RUN: fi
5 ; RUN: as < %s | opt -licm -adce -simplifycfg | dis | not grep 'br '
96
107 int %main(int %argc) {
118 br label %bb5
0 ; Promoting some values allows promotion of other values.
1 ; RUN: if as < %s | opt -mem2reg | dis | grep alloca
2 ; RUN: then exit 1
3 ; RUN: else exit 0
4 ; RUN: fi
1 ; RUN: as < %s | opt -mem2reg | dis | not grep alloca
52
63 int %test2() {
74 %result = alloca int ; ty=int*
11 ; generated code should perform the appropriate masking operations required
22 ; depending on the endianness of the target...
33
4 ; RUN: if as < %s | opt -mem2reg | dis | grep 'alloca'
5 ; RUN: then exit 1
6 ; RUN: else exit 0
7 ; RUN: fi
4 ; RUN: as < %s | opt -mem2reg | dis | not grep 'alloca'
85
96 implementation
107
0 ; Simple sanity check testcase. Both alloca's should be eliminated.
1 ; RUN: if as < %s | opt -mem2reg | dis | grep 'alloca'
2 ; RUN: then exit 1
3 ; RUN: else exit 0
4 ; RUN: fi
1 ; RUN: as < %s | opt -mem2reg | dis | not grep 'alloca'
52
63 implementation
74
None ; RUN: if as < %s | opt -pinodes -instcombine -die | dis | grep add
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -pinodes -instcombine -die | dis | not grep add
41
52 int "test"(int %i, int %j) {
63 %c = seteq int %i, 0
None ; RUN: if as < %s | opt -reassociate -instcombine -constprop -dce | dis | grep add
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -reassociate -instcombine -constprop -dce | dis | not grep add
41
5 int "test"(int %A) {
2 int %test(int %A) {
63 %X = add int %A, 1
74 %Y = add int %A, 1
85 %r = sub int %X, %Y
None ; RUN: if as < %s | opt -reassociate -instcombine -constprop -die | dis | grep 5
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -reassociate -instcombine -constprop -die | dis | not grep 5
41
5 int "test"(int %A, int %B) {
2 int %test(int %A, int %B) {
63 %W = add int %B, -5
74 %Y = add int %A, 5
85 %Z = add int %W, %Y
0 ; With sub reassociation, constant folding can eliminate all of the constants.
11 ;
2 ; RUN: if as < %s | opt -reassociate -constprop -instcombine -dce | dis | grep add
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -reassociate -constprop -instcombine -dce | dis | not grep add
63
7 int "test"(int %A, int %B) {
4 int %test(int %A, int %B) {
85 %W = add int 5, %B
96 %X = add int -7, %A
107 %Y = sub int %X, %W
0 ; With sub reassociation, constant folding can eliminate the two 12 constants.
11 ;
2 ; RUN: if as < %s | opt -reassociate -constprop -dce | dis | grep 12
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -reassociate -constprop -dce | dis | not grep 12
63
74 int "test"(int %A, int %B, int %C, int %D) {
85 %M = add int %A, 12
0 ; With reassociation, constant folding can eliminate the 12 and -12 constants.
11 ;
2 ; RUN: if as < %s | opt -reassociate -constprop -instcombine -die | dis | grep add
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -reassociate -constprop -instcombine -die | dis | not grep add
63
7 int "test"(int %arg) {
4 int %test(int %arg) {
85 %tmp1 = sub int -12, %arg
96 %tmp2 = add int %tmp1, 12
107 ret int %tmp2
0 ; With reassociation, constant folding can eliminate the +/- 30 constants.
11 ;
2 ; RUN: if as < %s | opt -reassociate -constprop -instcombine -die | dis | grep 30
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -reassociate -constprop -instcombine -die | dis | not grep 30
63
74 int "test"(int %reg109, int %reg1111) {
85 %reg115 = add int %reg109, -30 ; [#uses=1]
1111 ; In this case, we want to reassociate the specified expr so that i+j can be
1212 ; hoisted out of the inner most loop.
1313 ;
14 ; RUN: if as < %s | opt -reassociate | dis | grep 115 | grep 117
15 ; RUN: then exit 1
16 ; RUN: else exit 0
17 ; RUN: fi
14 ; RUN: as < %s | opt -reassociate | dis | grep 115 | not grep 117
1815
1916 %.LC0 = internal global [4 x sbyte] c"%d\0A\00" ; <[4 x sbyte]*> [#uses=1]
2017
0 ; Reassociation should apply to Add, Mul, And, Or, & Xor
11 ;
2 ; RUN: if as < %s | opt -reassociate -constprop -instcombine -die | dis | grep 12
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -reassociate -constprop -instcombine -die | dis | not grep 12
63
74 int "test_mul"(int %arg) {
85 %tmp1 = mul int 12, %arg
0 ; With sub reassociation, constant folding can eliminate the 12 and -12 constants.
11 ;
2 ; RUN: if as < %s | opt -reassociate -constprop -instcombine -die | dis | grep 12
3 ; RUN: then exit 1
4 ; RUN: else exit 0
5 ; RUN: fi
2 ; RUN: as < %s | opt -reassociate -constprop -instcombine -die | dis | not grep 12
63
74 int "test"(int %A, int %B) {
85 %X = add int -12, %A
44 ; real benchmark (mst from Olden benchmark, MakeGraph function). When SCCP is
55 ; fixed, this should be eliminated by a single SCCP application.
66 ;
7 ; RUN: if as < %s | opt -sccp | dis | grep loop
8 ; RUN: then exit 1
9 ; RUN: else exit 0
10 ; RUN: fi
7 ; RUN: as < %s | opt -sccp | dis | not grep loop
118
12 int *"test"()
13 begin
9 int* %test() {
1410 bb1:
1511 %A = malloc int
1612 br label %bb2
2319
2420 bb3:
2521 ret int * %A
26 end
27
22 }
None ; RUN: if as < %s | opt -sccp | dis | grep sub
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -sccp | dis | not grep sub
41
5 void "test3"(int, int)
6 begin
2 void %test3(int, int) {
73 add int 0, 0
84 sub int 0, 4
95 ret void
10 end
11
6 }
None ; RUN: if as < %s | opt -sccp | dis | grep '%X'
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -sccp | dis | not grep '%X'
41
52 %G = uninitialized global [40x int]
63
None ; RUN: if as < %s | opt -sccp -simplifycfg | dis | grep then:
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -sccp -simplifycfg | dis | not grep then:
41
52 void %cprop_test11(int* %data.1) {
63 entry: ; No predecessors!
0 ; This is a basic sanity check for constant propogation. The add instruction
11 ; should be eliminated.
22
3 ; RUN: if as < %s | opt -sccp | dis | grep add
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -sccp | dis | not grep add
74
8 int "test"(bool %B)
9 begin
5 int %test(bool %B) {
106 br bool %B, label %BB1, label %BB2
117 BB1:
128 %Val = add int 0, 0
1612 BB3:
1713 %Ret = phi int [%Val, %BB1], [1, %BB2]
1814 ret int %Ret
19 end
15 }
0 ; This is the test case taken from appel's book that illustrates a hard case
11 ; that SCCP gets right. BB3 should be completely eliminated.
22 ;
3 ; RUN: if as < %s | opt -sccp -constprop -dce -cfgsimplify | dis | grep BB3
4 ; RUN: then exit 1
5 ; RUN: else exit 0
6 ; RUN: fi
3 ; RUN: as < %s | opt -sccp -constprop -dce -cfgsimplify | dis | not grep BB3
74
8 int "test function"(int %i0, int %j0)
9 begin
5 int %test function(int %i0, int %j0) {
106 BB1:
117 br label %BB2
128 BB2:
3430 %j4 = phi int [1, %BB5], [%k2, %BB6]
3531 %k4 = phi int [%k3, %BB5], [%k5, %BB6]
3632 br label %BB2
37 end
38
33 }
None ; RUN: if as < %s | opt -scalarrepl -mem2reg | dis | grep alloca
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -scalarrepl -mem2reg | dis | not grep alloca
41
52 int %test() {
63 %X = alloca [ 4 x int ]
None ; RUN: if as < %s | opt -scalarrepl -mem2reg | dis | grep alloca
1 ; RUN: then exit 1
2 ; RUN: else exit 0
3 ; RUN: fi
0 ; RUN: as < %s | opt -scalarrepl -mem2reg | dis | not grep alloca
41
52 int %test() {
63 %X = alloca { int, float }