llvm.org GIT mirror llvm / 355f577
merge two tests and filecheckify git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123082 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 8 years ago
2 changed file(s) with 113 addition(s) and 103 deletion(s). Raw diff Collapse all Expand all
None ; RUN: opt < %s -memcpyopt -S | not grep store
1 ; RUN: opt < %s -memcpyopt -S | grep {call.*llvm.memset}
0 ; RUN: opt < %s -memcpyopt -S | FileCheck %s
21
32 ; All the stores in this example should be merged into a single memset.
43
54 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
65 target triple = "i386-apple-darwin8"
76
8 define void @foo(i8 signext %c) nounwind {
7 define void @test1(i8 signext %c) nounwind {
98 entry:
109 %x = alloca [19 x i8] ; <[19 x i8]*> [#uses=20]
1110 %tmp = getelementptr [19 x i8]* %x, i32 0, i32 0 ; [#uses=1]
4645 store i8 %c, i8* %tmp69, align 1
4746 %tmp73 = getelementptr [19 x i8]* %x, i32 0, i32 18 ; [#uses=1]
4847 store i8 %c, i8* %tmp73, align 1
49 %tmp76 = call i32 (...)* @bar( [19 x i8]* %x ) nounwind ; [#uses=0]
48 %tmp76 = call i32 (...)* @bar( [19 x i8]* %x ) nounwind
5049 ret void
50 ; CHECK: @test1
51 ; CHECK-NOT: store
52 ; CHECK: call void @llvm.memset.p0i8.i64
53 ; CHECK-NOT: store
54 ; CHECK: ret
5155 }
5256
5357 declare i32 @bar(...)
5458
59
60 %struct.MV = type { i16, i16 }
61
62 define void @test2() nounwind {
63 entry:
64 %ref_idx = alloca [8 x i8] ; <[8 x i8]*> [#uses=8]
65 %left_mvd = alloca [8 x %struct.MV] ; <[8 x %struct.MV]*> [#uses=17]
66 %up_mvd = alloca [8 x %struct.MV] ; <[8 x %struct.MV]*> [#uses=17]
67 %tmp20 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 7 ; [#uses=1]
68 store i8 -1, i8* %tmp20, align 1
69 %tmp23 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 6 ; [#uses=1]
70 store i8 -1, i8* %tmp23, align 1
71 %tmp26 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 5 ; [#uses=1]
72 store i8 -1, i8* %tmp26, align 1
73 %tmp29 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 4 ; [#uses=1]
74 store i8 -1, i8* %tmp29, align 1
75 %tmp32 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 3 ; [#uses=1]
76 store i8 -1, i8* %tmp32, align 1
77 %tmp35 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 2 ; [#uses=1]
78 store i8 -1, i8* %tmp35, align 1
79 %tmp38 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 1 ; [#uses=1]
80 store i8 -1, i8* %tmp38, align 1
81 %tmp41 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 0 ; [#uses=2]
82 store i8 -1, i8* %tmp41, align 1
83 %tmp43 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 7, i32 0 ; [#uses=1]
84 store i16 0, i16* %tmp43, align 2
85 %tmp46 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 7, i32 1 ; [#uses=1]
86 store i16 0, i16* %tmp46, align 2
87 %tmp57 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 6, i32 0 ; [#uses=1]
88 store i16 0, i16* %tmp57, align 2
89 %tmp60 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 6, i32 1 ; [#uses=1]
90 store i16 0, i16* %tmp60, align 2
91 %tmp71 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 5, i32 0 ; [#uses=1]
92 store i16 0, i16* %tmp71, align 2
93 %tmp74 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 5, i32 1 ; [#uses=1]
94 store i16 0, i16* %tmp74, align 2
95 %tmp85 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 4, i32 0 ; [#uses=1]
96 store i16 0, i16* %tmp85, align 2
97 %tmp88 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 4, i32 1 ; [#uses=1]
98 store i16 0, i16* %tmp88, align 2
99 %tmp99 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 3, i32 0 ; [#uses=1]
100 store i16 0, i16* %tmp99, align 2
101 %tmp102 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 3, i32 1 ; [#uses=1]
102 store i16 0, i16* %tmp102, align 2
103 %tmp113 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 2, i32 0 ; [#uses=1]
104 store i16 0, i16* %tmp113, align 2
105 %tmp116 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 2, i32 1 ; [#uses=1]
106 store i16 0, i16* %tmp116, align 2
107 %tmp127 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 1, i32 0 ; [#uses=1]
108 store i16 0, i16* %tmp127, align 2
109 %tmp130 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 1, i32 1 ; [#uses=1]
110 store i16 0, i16* %tmp130, align 2
111 %tmp141 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0, i32 0 ; [#uses=1]
112 store i16 0, i16* %tmp141, align 8
113 %tmp144 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0, i32 1 ; [#uses=1]
114 store i16 0, i16* %tmp144, align 2
115 %tmp148 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 7, i32 0 ; [#uses=1]
116 store i16 0, i16* %tmp148, align 2
117 %tmp151 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 7, i32 1 ; [#uses=1]
118 store i16 0, i16* %tmp151, align 2
119 %tmp162 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 6, i32 0 ; [#uses=1]
120 store i16 0, i16* %tmp162, align 2
121 %tmp165 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 6, i32 1 ; [#uses=1]
122 store i16 0, i16* %tmp165, align 2
123 %tmp176 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 5, i32 0 ; [#uses=1]
124 store i16 0, i16* %tmp176, align 2
125 %tmp179 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 5, i32 1 ; [#uses=1]
126 store i16 0, i16* %tmp179, align 2
127 %tmp190 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 4, i32 0 ; [#uses=1]
128 store i16 0, i16* %tmp190, align 2
129 %tmp193 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 4, i32 1 ; [#uses=1]
130 store i16 0, i16* %tmp193, align 2
131 %tmp204 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 3, i32 0 ; [#uses=1]
132 store i16 0, i16* %tmp204, align 2
133 %tmp207 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 3, i32 1 ; [#uses=1]
134 store i16 0, i16* %tmp207, align 2
135 %tmp218 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 2, i32 0 ; [#uses=1]
136 store i16 0, i16* %tmp218, align 2
137 %tmp221 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 2, i32 1 ; [#uses=1]
138 store i16 0, i16* %tmp221, align 2
139 %tmp232 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 1, i32 0 ; [#uses=1]
140 store i16 0, i16* %tmp232, align 2
141 %tmp235 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 1, i32 1 ; [#uses=1]
142 store i16 0, i16* %tmp235, align 2
143 %tmp246 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0, i32 0 ; [#uses=1]
144 store i16 0, i16* %tmp246, align 8
145 %tmp249 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0, i32 1 ; [#uses=1]
146 store i16 0, i16* %tmp249, align 2
147 %up_mvd252 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0 ; <%struct.MV*> [#uses=1]
148 %left_mvd253 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0 ; <%struct.MV*> [#uses=1]
149 call void @foo( %struct.MV* %up_mvd252, %struct.MV* %left_mvd253, i8* %tmp41 ) nounwind
150 ret void
151
152 ; CHECK: @test2
153 ; CHECK-NOT: store
154 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %tmp41, i8 -1, i64 8, i32 1, i1 false)
155 ; CHECK-NOT: store
156 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 32, i32 8, i1 false)
157 ; CHECK-NOT: store
158 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 32, i32 8, i1 false)
159 ; CHECK-NOT: store
160 ; CHECK: ret
161 }
162
163 declare void @foo(%struct.MV*, %struct.MV*, i8*)
+0
-99
test/Transforms/MemCpyOpt/form-memset2.ll less more
None ; RUN: opt < %s -memcpyopt -S | not grep store
1 ; RUN: opt < %s -memcpyopt -S | grep {call.*llvm.memset} | count 3
2
3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
4 target triple = "i386-apple-darwin8"
5 %struct.MV = type { i16, i16 }
6
7 define i32 @t() nounwind {
8 entry:
9 %ref_idx = alloca [8 x i8] ; <[8 x i8]*> [#uses=8]
10 %left_mvd = alloca [8 x %struct.MV] ; <[8 x %struct.MV]*> [#uses=17]
11 %up_mvd = alloca [8 x %struct.MV] ; <[8 x %struct.MV]*> [#uses=17]
12 %tmp20 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 7 ; [#uses=1]
13 store i8 -1, i8* %tmp20, align 1
14 %tmp23 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 6 ; [#uses=1]
15 store i8 -1, i8* %tmp23, align 1
16 %tmp26 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 5 ; [#uses=1]
17 store i8 -1, i8* %tmp26, align 1
18 %tmp29 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 4 ; [#uses=1]
19 store i8 -1, i8* %tmp29, align 1
20 %tmp32 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 3 ; [#uses=1]
21 store i8 -1, i8* %tmp32, align 1
22 %tmp35 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 2 ; [#uses=1]
23 store i8 -1, i8* %tmp35, align 1
24 %tmp38 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 1 ; [#uses=1]
25 store i8 -1, i8* %tmp38, align 1
26 %tmp41 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 0 ; [#uses=2]
27 store i8 -1, i8* %tmp41, align 1
28 %tmp43 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 7, i32 0 ; [#uses=1]
29 store i16 0, i16* %tmp43, align 2
30 %tmp46 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 7, i32 1 ; [#uses=1]
31 store i16 0, i16* %tmp46, align 2
32 %tmp57 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 6, i32 0 ; [#uses=1]
33 store i16 0, i16* %tmp57, align 2
34 %tmp60 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 6, i32 1 ; [#uses=1]
35 store i16 0, i16* %tmp60, align 2
36 %tmp71 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 5, i32 0 ; [#uses=1]
37 store i16 0, i16* %tmp71, align 2
38 %tmp74 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 5, i32 1 ; [#uses=1]
39 store i16 0, i16* %tmp74, align 2
40 %tmp85 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 4, i32 0 ; [#uses=1]
41 store i16 0, i16* %tmp85, align 2
42 %tmp88 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 4, i32 1 ; [#uses=1]
43 store i16 0, i16* %tmp88, align 2
44 %tmp99 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 3, i32 0 ; [#uses=1]
45 store i16 0, i16* %tmp99, align 2
46 %tmp102 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 3, i32 1 ; [#uses=1]
47 store i16 0, i16* %tmp102, align 2
48 %tmp113 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 2, i32 0 ; [#uses=1]
49 store i16 0, i16* %tmp113, align 2
50 %tmp116 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 2, i32 1 ; [#uses=1]
51 store i16 0, i16* %tmp116, align 2
52 %tmp127 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 1, i32 0 ; [#uses=1]
53 store i16 0, i16* %tmp127, align 2
54 %tmp130 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 1, i32 1 ; [#uses=1]
55 store i16 0, i16* %tmp130, align 2
56 %tmp141 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0, i32 0 ; [#uses=1]
57 store i16 0, i16* %tmp141, align 8
58 %tmp144 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0, i32 1 ; [#uses=1]
59 store i16 0, i16* %tmp144, align 2
60 %tmp148 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 7, i32 0 ; [#uses=1]
61 store i16 0, i16* %tmp148, align 2
62 %tmp151 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 7, i32 1 ; [#uses=1]
63 store i16 0, i16* %tmp151, align 2
64 %tmp162 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 6, i32 0 ; [#uses=1]
65 store i16 0, i16* %tmp162, align 2
66 %tmp165 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 6, i32 1 ; [#uses=1]
67 store i16 0, i16* %tmp165, align 2
68 %tmp176 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 5, i32 0 ; [#uses=1]
69 store i16 0, i16* %tmp176, align 2
70 %tmp179 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 5, i32 1 ; [#uses=1]
71 store i16 0, i16* %tmp179, align 2
72 %tmp190 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 4, i32 0 ; [#uses=1]
73 store i16 0, i16* %tmp190, align 2
74 %tmp193 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 4, i32 1 ; [#uses=1]
75 store i16 0, i16* %tmp193, align 2
76 %tmp204 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 3, i32 0 ; [#uses=1]
77 store i16 0, i16* %tmp204, align 2
78 %tmp207 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 3, i32 1 ; [#uses=1]
79 store i16 0, i16* %tmp207, align 2
80 %tmp218 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 2, i32 0 ; [#uses=1]
81 store i16 0, i16* %tmp218, align 2
82 %tmp221 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 2, i32 1 ; [#uses=1]
83 store i16 0, i16* %tmp221, align 2
84 %tmp232 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 1, i32 0 ; [#uses=1]
85 store i16 0, i16* %tmp232, align 2
86 %tmp235 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 1, i32 1 ; [#uses=1]
87 store i16 0, i16* %tmp235, align 2
88 %tmp246 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0, i32 0 ; [#uses=1]
89 store i16 0, i16* %tmp246, align 8
90 %tmp249 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0, i32 1 ; [#uses=1]
91 store i16 0, i16* %tmp249, align 2
92 %up_mvd252 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0 ; <%struct.MV*> [#uses=1]
93 %left_mvd253 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0 ; <%struct.MV*> [#uses=1]
94 call void @foo( %struct.MV* %up_mvd252, %struct.MV* %left_mvd253, i8* %tmp41 ) nounwind
95 ret i32 undef
96 }
97
98 declare void @foo(%struct.MV*, %struct.MV*, i8*)