1 ; RUN: opt -S -dse < %s | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 ; This test is not relevant for DSE with MemorySSA. Non-memory instructions
5 ; are ignored anyways. The limits for the MemorySSA traversal are tested in
6 ; llvm/test/Transforms/DeadStoreElimination/MSSA/memoryssa-scan-limit.ll
8 @x = global i32 0, align 4
10 ; Function Attrs: nounwind
11 define i32 @test_within_limit() !dbg !4 {
13 ; The first store; later there is a second store to the same location,
14 ; so this store should be optimized away by DSE.
15 ; CHECK-NOT: store i32 1, i32* @x, align 4
16 store i32 1, i32* @x, align 4
18 ; Insert 98 dummy instructions between the two stores
19 %0 = bitcast i32 0 to i32
20 %1 = bitcast i32 0 to i32
21 %2 = bitcast i32 0 to i32
22 %3 = bitcast i32 0 to i32
23 %4 = bitcast i32 0 to i32
24 %5 = bitcast i32 0 to i32
25 %6 = bitcast i32 0 to i32
26 %7 = bitcast i32 0 to i32
27 %8 = bitcast i32 0 to i32
28 %9 = bitcast i32 0 to i32
29 %10 = bitcast i32 0 to i32
30 %11 = bitcast i32 0 to i32
31 %12 = bitcast i32 0 to i32
32 %13 = bitcast i32 0 to i32
33 %14 = bitcast i32 0 to i32
34 %15 = bitcast i32 0 to i32
35 %16 = bitcast i32 0 to i32
36 %17 = bitcast i32 0 to i32
37 %18 = bitcast i32 0 to i32
38 %19 = bitcast i32 0 to i32
39 %20 = bitcast i32 0 to i32
40 %21 = bitcast i32 0 to i32
41 %22 = bitcast i32 0 to i32
42 %23 = bitcast i32 0 to i32
43 %24 = bitcast i32 0 to i32
44 %25 = bitcast i32 0 to i32
45 %26 = bitcast i32 0 to i32
46 %27 = bitcast i32 0 to i32
47 %28 = bitcast i32 0 to i32
48 %29 = bitcast i32 0 to i32
49 %30 = bitcast i32 0 to i32
50 %31 = bitcast i32 0 to i32
51 %32 = bitcast i32 0 to i32
52 %33 = bitcast i32 0 to i32
53 %34 = bitcast i32 0 to i32
54 %35 = bitcast i32 0 to i32
55 %36 = bitcast i32 0 to i32
56 %37 = bitcast i32 0 to i32
57 %38 = bitcast i32 0 to i32
58 %39 = bitcast i32 0 to i32
59 %40 = bitcast i32 0 to i32
60 %41 = bitcast i32 0 to i32
61 %42 = bitcast i32 0 to i32
62 %43 = bitcast i32 0 to i32
63 %44 = bitcast i32 0 to i32
64 %45 = bitcast i32 0 to i32
65 %46 = bitcast i32 0 to i32
66 %47 = bitcast i32 0 to i32
67 %48 = bitcast i32 0 to i32
68 %49 = bitcast i32 0 to i32
69 %50 = bitcast i32 0 to i32
70 %51 = bitcast i32 0 to i32
71 %52 = bitcast i32 0 to i32
72 %53 = bitcast i32 0 to i32
73 %54 = bitcast i32 0 to i32
74 %55 = bitcast i32 0 to i32
75 %56 = bitcast i32 0 to i32
76 %57 = bitcast i32 0 to i32
77 %58 = bitcast i32 0 to i32
78 %59 = bitcast i32 0 to i32
79 %60 = bitcast i32 0 to i32
80 %61 = bitcast i32 0 to i32
81 %62 = bitcast i32 0 to i32
82 %63 = bitcast i32 0 to i32
83 %64 = bitcast i32 0 to i32
84 %65 = bitcast i32 0 to i32
85 %66 = bitcast i32 0 to i32
86 %67 = bitcast i32 0 to i32
87 %68 = bitcast i32 0 to i32
88 %69 = bitcast i32 0 to i32
89 %70 = bitcast i32 0 to i32
90 %71 = bitcast i32 0 to i32
91 %72 = bitcast i32 0 to i32
92 %73 = bitcast i32 0 to i32
93 %74 = bitcast i32 0 to i32
94 %75 = bitcast i32 0 to i32
95 %76 = bitcast i32 0 to i32
96 %77 = bitcast i32 0 to i32
97 %78 = bitcast i32 0 to i32
98 %79 = bitcast i32 0 to i32
99 %80 = bitcast i32 0 to i32
100 %81 = bitcast i32 0 to i32
101 %82 = bitcast i32 0 to i32
102 %83 = bitcast i32 0 to i32
103 %84 = bitcast i32 0 to i32
104 %85 = bitcast i32 0 to i32
105 %86 = bitcast i32 0 to i32
106 %87 = bitcast i32 0 to i32
107 %88 = bitcast i32 0 to i32
108 %89 = bitcast i32 0 to i32
109 %90 = bitcast i32 0 to i32
110 %91 = bitcast i32 0 to i32
111 %92 = bitcast i32 0 to i32
112 %93 = bitcast i32 0 to i32
113 %94 = bitcast i32 0 to i32
114 %95 = bitcast i32 0 to i32
115 %96 = bitcast i32 0 to i32
116 %97 = bitcast i32 0 to i32
118 ; Insert a meaningless dbg.value intrinsic; it should have no
119 ; effect on the working of DSE in any way.
120 call void @llvm.dbg.value(metadata i32 undef, metadata !10, metadata !DIExpression()), !dbg !DILocation(scope: !4)
122 ; CHECK: store i32 -1, i32* @x, align 4
123 store i32 -1, i32* @x, align 4
127 ; Function Attrs: nounwind
128 define i32 @test_outside_limit() {
130 ; The first store; later there is a second store to the same location
131 ; CHECK-NOT: store i32 1, i32* @x, align 4
132 store i32 1, i32* @x, align 4
134 ; Insert 99 dummy instructions between the two stores; this is
135 ; one too many instruction for the DSE to take place.
136 %0 = bitcast i32 0 to i32
137 %1 = bitcast i32 0 to i32
138 %2 = bitcast i32 0 to i32
139 %3 = bitcast i32 0 to i32
140 %4 = bitcast i32 0 to i32
141 %5 = bitcast i32 0 to i32
142 %6 = bitcast i32 0 to i32
143 %7 = bitcast i32 0 to i32
144 %8 = bitcast i32 0 to i32
145 %9 = bitcast i32 0 to i32
146 %10 = bitcast i32 0 to i32
147 %11 = bitcast i32 0 to i32
148 %12 = bitcast i32 0 to i32
149 %13 = bitcast i32 0 to i32
150 %14 = bitcast i32 0 to i32
151 %15 = bitcast i32 0 to i32
152 %16 = bitcast i32 0 to i32
153 %17 = bitcast i32 0 to i32
154 %18 = bitcast i32 0 to i32
155 %19 = bitcast i32 0 to i32
156 %20 = bitcast i32 0 to i32
157 %21 = bitcast i32 0 to i32
158 %22 = bitcast i32 0 to i32
159 %23 = bitcast i32 0 to i32
160 %24 = bitcast i32 0 to i32
161 %25 = bitcast i32 0 to i32
162 %26 = bitcast i32 0 to i32
163 %27 = bitcast i32 0 to i32
164 %28 = bitcast i32 0 to i32
165 %29 = bitcast i32 0 to i32
166 %30 = bitcast i32 0 to i32
167 %31 = bitcast i32 0 to i32
168 %32 = bitcast i32 0 to i32
169 %33 = bitcast i32 0 to i32
170 %34 = bitcast i32 0 to i32
171 %35 = bitcast i32 0 to i32
172 %36 = bitcast i32 0 to i32
173 %37 = bitcast i32 0 to i32
174 %38 = bitcast i32 0 to i32
175 %39 = bitcast i32 0 to i32
176 %40 = bitcast i32 0 to i32
177 %41 = bitcast i32 0 to i32
178 %42 = bitcast i32 0 to i32
179 %43 = bitcast i32 0 to i32
180 %44 = bitcast i32 0 to i32
181 %45 = bitcast i32 0 to i32
182 %46 = bitcast i32 0 to i32
183 %47 = bitcast i32 0 to i32
184 %48 = bitcast i32 0 to i32
185 %49 = bitcast i32 0 to i32
186 %50 = bitcast i32 0 to i32
187 %51 = bitcast i32 0 to i32
188 %52 = bitcast i32 0 to i32
189 %53 = bitcast i32 0 to i32
190 %54 = bitcast i32 0 to i32
191 %55 = bitcast i32 0 to i32
192 %56 = bitcast i32 0 to i32
193 %57 = bitcast i32 0 to i32
194 %58 = bitcast i32 0 to i32
195 %59 = bitcast i32 0 to i32
196 %60 = bitcast i32 0 to i32
197 %61 = bitcast i32 0 to i32
198 %62 = bitcast i32 0 to i32
199 %63 = bitcast i32 0 to i32
200 %64 = bitcast i32 0 to i32
201 %65 = bitcast i32 0 to i32
202 %66 = bitcast i32 0 to i32
203 %67 = bitcast i32 0 to i32
204 %68 = bitcast i32 0 to i32
205 %69 = bitcast i32 0 to i32
206 %70 = bitcast i32 0 to i32
207 %71 = bitcast i32 0 to i32
208 %72 = bitcast i32 0 to i32
209 %73 = bitcast i32 0 to i32
210 %74 = bitcast i32 0 to i32
211 %75 = bitcast i32 0 to i32
212 %76 = bitcast i32 0 to i32
213 %77 = bitcast i32 0 to i32
214 %78 = bitcast i32 0 to i32
215 %79 = bitcast i32 0 to i32
216 %80 = bitcast i32 0 to i32
217 %81 = bitcast i32 0 to i32
218 %82 = bitcast i32 0 to i32
219 %83 = bitcast i32 0 to i32
220 %84 = bitcast i32 0 to i32
221 %85 = bitcast i32 0 to i32
222 %86 = bitcast i32 0 to i32
223 %87 = bitcast i32 0 to i32
224 %88 = bitcast i32 0 to i32
225 %89 = bitcast i32 0 to i32
226 %90 = bitcast i32 0 to i32
227 %91 = bitcast i32 0 to i32
228 %92 = bitcast i32 0 to i32
229 %93 = bitcast i32 0 to i32
230 %94 = bitcast i32 0 to i32
231 %95 = bitcast i32 0 to i32
232 %96 = bitcast i32 0 to i32
233 %97 = bitcast i32 0 to i32
234 %98 = bitcast i32 0 to i32
236 ; CHECK: store i32 -1, i32* @x, align 4
237 store i32 -1, i32* @x, align 4
241 ; Function Attrs: nounwind readnone
242 declare void @llvm.dbg.value(metadata, metadata, metadata)
245 !llvm.module.flags = !{!11, !13}
247 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
248 !1 = !DIFile(filename: "test.c", directory: "/home/tmp")
250 !4 = distinct !DISubprogram(name: "test_within_limit", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 4, file: !1, scope: !5, type: !6, retainedNodes: !2)
251 !5 = !DIFile(filename: "test.c", directory: "/home/tmp")
252 !6 = !DISubroutineType(types: !7)
254 !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
256 !10 = !DILocalVariable(name: "x", scope: !4, type: !8)
257 !11 = !{i32 2, !"Dwarf Version", i32 4}
260 !13 = !{i32 1, !"Debug Info Version", i32 3}