1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
5 define ptr addrspace(1) @test(<2 x ptr addrspace(1)> %vec, i32 %idx) gc "statepoint-example" {
8 ; CHECK-NEXT: [[OBJ:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC:%.*]], i32 [[IDX:%.*]]
9 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) [[OBJ]]) ]
10 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
11 ; CHECK-NEXT: ret ptr addrspace(1) [[OBJ_RELOCATED]]
13 ; Note that the second extractelement is actually redundant here. A correct output would
14 ; be to reuse the existing obj as a base since it is actually a base pointer.
16 %obj = extractelement <2 x ptr addrspace(1)> %vec, i32 %idx
17 call void @do_safepoint() [ "deopt"() ]
18 ret ptr addrspace(1) %obj
21 define ptr addrspace(1) @test2(ptr %ptr, i1 %cnd, i32 %idx1, i32 %idx2) gc "statepoint-example" {
22 ; CHECK-LABEL: @test2(
24 ; CHECK-NEXT: br i1 [[CND:%.*]], label [[TAKEN:%.*]], label [[UNTAKEN:%.*]]
26 ; CHECK-NEXT: [[OBJA:%.*]] = load <2 x ptr addrspace(1)>, ptr [[PTR:%.*]], align 16
27 ; CHECK-NEXT: br label [[MERGE:%.*]]
29 ; CHECK-NEXT: [[OBJB:%.*]] = load <2 x ptr addrspace(1)>, ptr [[PTR]], align 16
30 ; CHECK-NEXT: br label [[MERGE]]
32 ; CHECK-NEXT: [[VEC:%.*]] = phi <2 x ptr addrspace(1)> [ [[OBJA]], [[TAKEN]] ], [ [[OBJB]], [[UNTAKEN]] ]
33 ; CHECK-NEXT: br i1 [[CND]], label [[TAKEN2:%.*]], label [[UNTAKEN2:%.*]]
35 ; CHECK-NEXT: [[OBJ0:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 [[IDX1:%.*]]
36 ; CHECK-NEXT: br label [[MERGE2:%.*]]
38 ; CHECK-NEXT: [[OBJ1:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 [[IDX2:%.*]]
39 ; CHECK-NEXT: br label [[MERGE2]]
41 ; CHECK-NEXT: [[OBJ:%.*]] = phi ptr addrspace(1) [ [[OBJ0]], [[TAKEN2]] ], [ [[OBJ1]], [[UNTAKEN2]] ]
42 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) [[OBJ]]) ]
43 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
44 ; CHECK-NEXT: ret ptr addrspace(1) [[OBJ_RELOCATED]]
47 br i1 %cnd, label %taken, label %untaken
49 taken: ; preds = %entry
50 %obja = load <2 x ptr addrspace(1)>, ptr %ptr
53 untaken: ; preds = %entry
54 %objb = load <2 x ptr addrspace(1)>, ptr %ptr
57 merge: ; preds = %untaken, %taken
58 %vec = phi <2 x ptr addrspace(1)> [ %obja, %taken ], [ %objb, %untaken ]
59 br i1 %cnd, label %taken2, label %untaken2
61 taken2: ; preds = %merge
62 %obj0 = extractelement <2 x ptr addrspace(1)> %vec, i32 %idx1
65 untaken2: ; preds = %merge
66 %obj1 = extractelement <2 x ptr addrspace(1)> %vec, i32 %idx2
69 merge2: ; preds = %untaken2, %taken2
70 %obj = phi ptr addrspace(1) [ %obj0, %taken2 ], [ %obj1, %untaken2 ]
71 call void @do_safepoint() [ "deopt"() ]
72 ret ptr addrspace(1) %obj
75 define ptr addrspace(1) @test3(ptr addrspace(1) %ptr) gc "statepoint-example" {
76 ; CHECK-LABEL: @test3(
78 ; CHECK-NEXT: [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[PTR:%.*]], i32 0, !is_base_value !0
79 ; CHECK-NEXT: [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[PTR]], i32 0
80 ; CHECK-NEXT: [[OBJ_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i32 0, !is_base_value !0
81 ; CHECK-NEXT: [[OBJ:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 0
82 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) [[OBJ]], ptr addrspace(1) [[OBJ_BASE]]) ]
83 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
84 ; CHECK-NEXT: [[OBJ_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
85 ; CHECK-NEXT: ret ptr addrspace(1) [[OBJ_RELOCATED]]
88 %vec = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) %ptr, i32 0
89 %obj = extractelement <2 x ptr addrspace(1)> %vec, i32 0
90 call void @do_safepoint() [ "deopt"() ]
91 ret ptr addrspace(1) %obj
94 define ptr addrspace(1) @test4(ptr addrspace(1) %ptr) gc "statepoint-example" {
95 ; CHECK-LABEL: @test4(
97 ; CHECK-NEXT: [[DERIVED:%.*]] = getelementptr i64, ptr addrspace(1) [[PTR:%.*]], i64 16
98 ; CHECK-NEXT: [[VECA_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[PTR]], i32 0, !is_base_value !0
99 ; CHECK-NEXT: [[VECA:%.*]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[DERIVED]], i32 0
100 ; CHECK-NEXT: [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> [[VECA_BASE]], ptr addrspace(1) [[PTR]], i32 1, !is_base_value !0
101 ; CHECK-NEXT: [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> [[VECA]], ptr addrspace(1) [[PTR]], i32 1
102 ; CHECK-NEXT: [[OBJ_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i32 0, !is_base_value !0
103 ; CHECK-NEXT: [[OBJ:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 0
104 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) [[OBJ]], ptr addrspace(1) [[OBJ_BASE]]) ]
105 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
106 ; CHECK-NEXT: [[OBJ_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
107 ; CHECK-NEXT: ret ptr addrspace(1) [[OBJ_RELOCATED]]
109 ; When we can optimize an extractelement from a known
110 ; index and avoid introducing new base pointer instructions
112 %derived = getelementptr i64, ptr addrspace(1) %ptr, i64 16
113 %veca = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) %derived, i32 0
114 %vec = insertelement <2 x ptr addrspace(1)> %veca, ptr addrspace(1) %ptr, i32 1
115 %obj = extractelement <2 x ptr addrspace(1)> %vec, i32 0
116 call void @do_safepoint() [ "deopt"() ]
117 ret ptr addrspace(1) %obj
120 declare void @use(ptr addrspace(1)) "gc-leaf-function"
121 declare void @use_vec(<4 x ptr addrspace(1)>) "gc-leaf-function"
123 define void @test5(i1 %cnd, ptr addrspace(1) %obj) gc "statepoint-example" {
124 ; CHECK-LABEL: @test5(
126 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ:%.*]], i64 1
127 ; CHECK-NEXT: [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ]], i32 0, !is_base_value !0
128 ; CHECK-NEXT: [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[GEP]], i32 0
129 ; CHECK-NEXT: [[BDV_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i32 0, !is_base_value !0
130 ; CHECK-NEXT: [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 0
131 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]], ptr addrspace(1) [[BDV_BASE]]) ]
132 ; CHECK-NEXT: [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
133 ; CHECK-NEXT: [[BDV_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
134 ; CHECK-NEXT: call void @use(ptr addrspace(1) [[BDV_RELOCATED]])
135 ; CHECK-NEXT: ret void
137 ; When we fundementally have to duplicate
139 %gep = getelementptr i64, ptr addrspace(1) %obj, i64 1
140 %vec = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) %gep, i32 0
141 %bdv = extractelement <2 x ptr addrspace(1)> %vec, i32 0
142 call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
143 call void @use(ptr addrspace(1) %bdv)
147 define void @test6(i1 %cnd, ptr addrspace(1) %obj, i64 %idx) gc "statepoint-example" {
148 ; CHECK-LABEL: @test6(
150 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ:%.*]], i64 1
151 ; CHECK-NEXT: [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ]], i32 0, !is_base_value !0
152 ; CHECK-NEXT: [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[GEP]], i32 0
153 ; CHECK-NEXT: [[BDV_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i64 [[IDX:%.*]], !is_base_value !0
154 ; CHECK-NEXT: [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i64 [[IDX]]
155 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]], ptr addrspace(1) [[BDV_BASE]]) ]
156 ; CHECK-NEXT: [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
157 ; CHECK-NEXT: [[BDV_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
158 ; CHECK-NEXT: call void @use(ptr addrspace(1) [[BDV_RELOCATED]])
159 ; CHECK-NEXT: ret void
161 ; A more complicated example involving vector and scalar bases.
162 ; This is derived from a failing test case when we didn't have correct
163 ; insertelement handling.
165 %gep = getelementptr i64, ptr addrspace(1) %obj, i64 1
166 %vec = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) %gep, i32 0
167 %bdv = extractelement <2 x ptr addrspace(1)> %vec, i64 %idx
168 call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
169 call void @use(ptr addrspace(1) %bdv)
173 define ptr addrspace(1) @test7(i1 %cnd, ptr addrspace(1) %obj, ptr addrspace(1) %obj2) gc "statepoint-example" {
174 ; CHECK-LABEL: @test7(
176 ; CHECK-NEXT: [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ2:%.*]], i32 0, !is_base_value !0
177 ; CHECK-NEXT: [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[OBJ2]], i32 0
178 ; CHECK-NEXT: br label [[MERGE1:%.*]]
180 ; CHECK-NEXT: [[VEC2_BASE:%.*]] = phi <2 x ptr addrspace(1)> [ [[VEC_BASE]], [[ENTRY:%.*]] ], [ [[VEC3_BASE:%.*]], [[MERGE1]] ], !is_base_value !0
181 ; CHECK-NEXT: [[VEC2:%.*]] = phi <2 x ptr addrspace(1)> [ [[VEC]], [[ENTRY]] ], [ [[VEC3:%.*]], [[MERGE1]] ]
182 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ2]], i64 1
183 ; CHECK-NEXT: [[VEC3_BASE]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ2]], i32 0, !is_base_value !0
184 ; CHECK-NEXT: [[VEC3]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[GEP]], i32 0
185 ; CHECK-NEXT: br i1 [[CND:%.*]], label [[MERGE1]], label [[NEXT1:%.*]]
187 ; CHECK-NEXT: [[BDV_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC2_BASE]], i32 0, !is_base_value !0
188 ; CHECK-NEXT: [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC2]], i32 0
189 ; CHECK-NEXT: br label [[MERGE:%.*]]
191 ; CHECK-NEXT: [[OBJB_BASE:%.*]] = phi ptr addrspace(1) [ [[OBJ:%.*]], [[NEXT1]] ], [ [[BDV_BASE]], [[MERGE]] ], !is_base_value !0
192 ; CHECK-NEXT: [[OBJB:%.*]] = phi ptr addrspace(1) [ [[OBJ]], [[NEXT1]] ], [ [[BDV]], [[MERGE]] ]
193 ; CHECK-NEXT: br i1 [[CND]], label [[MERGE]], label [[NEXT:%.*]]
195 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[OBJB]], ptr addrspace(1) [[OBJB_BASE]]) ]
196 ; CHECK-NEXT: [[OBJB_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
197 ; CHECK-NEXT: [[OBJB_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
198 ; CHECK-NEXT: ret ptr addrspace(1) [[OBJB_RELOCATED]]
201 %vec = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) %obj2, i32 0
204 merge1: ; preds = %merge1, %entry
205 %vec2 = phi <2 x ptr addrspace(1)> [ %vec, %entry ], [ %vec3, %merge1 ]
206 %gep = getelementptr i64, ptr addrspace(1) %obj2, i64 1
207 %vec3 = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) %gep, i32 0
208 br i1 %cnd, label %merge1, label %next1
210 next1: ; preds = %merge1
211 %bdv = extractelement <2 x ptr addrspace(1)> %vec2, i32 0
214 merge: ; preds = %merge, %next1
215 %objb = phi ptr addrspace(1) [ %obj, %next1 ], [ %bdv, %merge ]
216 br i1 %cnd, label %merge, label %next
218 next: ; preds = %merge
219 call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
220 ret ptr addrspace(1) %objb
223 ; identify base for shufflevector
224 define void @test8(ptr addrspace(1) %obj, i64 %idx) gc "statepoint-example" {
225 ; CHECK-LABEL: @test8(
227 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ:%.*]], i64 1
228 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ]], i64 2
229 ; CHECK-NEXT: [[VEC1_BASE:%.*]] = insertelement <4 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ]], i32 0, !is_base_value !0
230 ; CHECK-NEXT: [[VEC1:%.*]] = insertelement <4 x ptr addrspace(1)> poison, ptr addrspace(1) [[GEP]], i32 0
231 ; CHECK-NEXT: [[VEC2_BASE:%.*]] = insertelement <4 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ]], i32 2, !is_base_value !0
232 ; CHECK-NEXT: [[VEC2:%.*]] = insertelement <4 x ptr addrspace(1)> poison, ptr addrspace(1) [[GEP2]], i32 2
233 ; CHECK-NEXT: [[VEC_BASE:%.*]] = shufflevector <4 x ptr addrspace(1)> [[VEC1_BASE]], <4 x ptr addrspace(1)> [[VEC2_BASE]], <2 x i32> <i32 0, i32 2>, !is_base_value !0
234 ; CHECK-NEXT: [[VEC:%.*]] = shufflevector <4 x ptr addrspace(1)> [[VEC1]], <4 x ptr addrspace(1)> [[VEC2]], <2 x i32> <i32 0, i32 2>
235 ; CHECK-NEXT: [[BDV_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i64 [[IDX:%.*]], !is_base_value !0
236 ; CHECK-NEXT: [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i64 [[IDX]]
237 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]], ptr addrspace(1) [[BDV_BASE]]) ]
238 ; CHECK-NEXT: [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
239 ; CHECK-NEXT: [[BDV_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
240 ; CHECK-NEXT: call void @use(ptr addrspace(1) [[BDV_RELOCATED]])
241 ; CHECK-NEXT: ret void
244 %gep = getelementptr i64, ptr addrspace(1) %obj, i64 1
245 %gep2 = getelementptr i64, ptr addrspace(1) %obj, i64 2
246 %vec1 = insertelement <4 x ptr addrspace(1)> poison, ptr addrspace(1) %gep, i32 0
247 %vec2 = insertelement <4 x ptr addrspace(1)> poison, ptr addrspace(1) %gep2, i32 2
248 %vec = shufflevector <4 x ptr addrspace(1)> %vec1, <4 x ptr addrspace(1)> %vec2, <2 x i32> <i32 0, i32 2>
249 %bdv = extractelement <2 x ptr addrspace(1)> %vec, i64 %idx
250 call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
251 call void @use(ptr addrspace(1) %bdv)
255 ; Since the same 'base' vector is used in the shuffle operands, we do not need
256 ; create a shufflevector base.
257 define void @test9(<4 x ptr addrspace(1)> %vec1, i64 %idx) gc "statepoint-example" {
258 ; CHECK-LABEL: @test9(
260 ; CHECK-NEXT: [[VEC:%.*]] = shufflevector <4 x ptr addrspace(1)> [[VEC1:%.*]], <4 x ptr addrspace(1)> [[VEC1]], <2 x i32> <i32 0, i32 2>
261 ; CHECK-NEXT: [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i64 [[IDX:%.*]]
262 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]]) ]
263 ; CHECK-NEXT: [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
264 ; CHECK-NEXT: call void @use(ptr addrspace(1) [[BDV_RELOCATED]])
265 ; CHECK-NEXT: ret void
268 ; shrinking vec1 into vec
269 %vec = shufflevector <4 x ptr addrspace(1)> %vec1, <4 x ptr addrspace(1)> %vec1, <2 x i32> <i32 0, i32 2>
270 %bdv = extractelement <2 x ptr addrspace(1)> %vec, i64 %idx
271 call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
272 call void @use(ptr addrspace(1) %bdv)
276 ; vector operand of shufflevector is a phi
277 define ptr addrspace(1) @test10(i1 %cnd, ptr addrspace(1) %obj, ptr addrspace(1) %obj2) gc "statepoint-example" {
278 ; CHECK-LABEL: @test10(
280 ; CHECK-NEXT: [[VEC1_BASE:%.*]] = insertelement <4 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ:%.*]], i32 0, !is_base_value !0
281 ; CHECK-NEXT: [[VEC1:%.*]] = insertelement <4 x ptr addrspace(1)> poison, ptr addrspace(1) [[OBJ]], i32 0
282 ; CHECK-NEXT: br i1 [[CND:%.*]], label [[HERE:%.*]], label [[MERGE:%.*]]
284 ; CHECK-NEXT: [[VEC2_BASE:%.*]] = insertelement <4 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ2:%.*]], i32 2, !is_base_value !0
285 ; CHECK-NEXT: [[VEC2:%.*]] = insertelement <4 x ptr addrspace(1)> poison, ptr addrspace(1) [[OBJ2]], i32 2
286 ; CHECK-NEXT: br label [[MERGE]]
288 ; CHECK-NEXT: [[VEC_BASE:%.*]] = phi <4 x ptr addrspace(1)> [ [[VEC1_BASE]], [[ENTRY:%.*]] ], [ [[VEC2_BASE]], [[HERE]] ], [ [[VEC3_BASE:%.*]], [[MERGE]] ], !is_base_value !0
289 ; CHECK-NEXT: [[VEC:%.*]] = phi <4 x ptr addrspace(1)> [ [[VEC1]], [[ENTRY]] ], [ [[VEC2]], [[HERE]] ], [ [[VEC3:%.*]], [[MERGE]] ]
290 ; CHECK-NEXT: [[VEC3_BASE]] = shufflevector <4 x ptr addrspace(1)> [[VEC_BASE]], <4 x ptr addrspace(1)> [[VEC_BASE]], <4 x i32> <i32 2, i32 0, i32 1, i32 3>, !is_base_value !0
291 ; CHECK-NEXT: [[VEC3]] = shufflevector <4 x ptr addrspace(1)> [[VEC]], <4 x ptr addrspace(1)> [[VEC]], <4 x i32> <i32 2, i32 0, i32 1, i32 3>
292 ; CHECK-NEXT: [[BDV_BASE:%.*]] = extractelement <4 x ptr addrspace(1)> [[VEC3_BASE]], i32 0, !is_base_value !0
293 ; CHECK-NEXT: [[BDV:%.*]] = extractelement <4 x ptr addrspace(1)> [[VEC3]], i32 0
294 ; CHECK-NEXT: br i1 [[CND]], label [[MERGE]], label [[NEXT:%.*]]
296 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]], ptr addrspace(1) [[BDV_BASE]]) ]
297 ; CHECK-NEXT: [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
298 ; CHECK-NEXT: [[BDV_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
299 ; CHECK-NEXT: ret ptr addrspace(1) [[BDV_RELOCATED]]
302 %vec1 = insertelement <4 x ptr addrspace(1)> poison, ptr addrspace(1) %obj, i32 0
303 br i1 %cnd, label %here, label %merge
306 %vec2 = insertelement <4 x ptr addrspace(1)> poison, ptr addrspace(1) %obj2, i32 2
309 merge: ; preds = %merge, %entry, %here
310 %vec = phi <4 x ptr addrspace(1)> [ %vec1, %entry ], [ %vec2, %here], [ %vec3, %merge]
311 %vec3 = shufflevector <4 x ptr addrspace(1)> %vec, <4 x ptr addrspace(1)> %vec, <4 x i32> <i32 2, i32 0, i32 1, i32 3>
312 %bdv = extractelement <4 x ptr addrspace(1)> %vec3, i32 0
313 br i1 %cnd, label %merge, label %next
316 call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
317 ret ptr addrspace(1) %bdv
319 declare void @do_safepoint()
321 define void @test11(<4 x ptr addrspace(1)> %vec1) gc "statepoint-example" {
322 ; CHECK-LABEL: @test11(
324 ; CHECK-NEXT: [[VEC2:%.*]] = getelementptr i64, <4 x ptr addrspace(1)> [[VEC1:%.*]], i32 1024
325 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(<4 x ptr addrspace(1)> [[VEC1]]) ]
326 ; CHECK-NEXT: [[VEC1_RELOCATED:%.*]] = call coldcc <4 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v4p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
327 ; CHECK-NEXT: [[VEC2_REMAT:%.*]] = getelementptr i64, <4 x ptr addrspace(1)> [[VEC1_RELOCATED]], i32 1024
328 ; CHECK-NEXT: call void @use_vec(<4 x ptr addrspace(1)> [[VEC2_REMAT]])
329 ; CHECK-NEXT: ret void
332 %vec2 = getelementptr i64, <4 x ptr addrspace(1)> %vec1, i32 1024
333 call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
334 call void @use_vec(<4 x ptr addrspace(1)> %vec2)
338 declare <4 x ptr addrspace(1)> @def_vec() "gc-leaf-function"
340 define void @test12(<4 x ptr addrspace(1)> %vec1) gc "statepoint-example" {
341 ; CHECK-LABEL: @test12(
343 ; CHECK-NEXT: [[VEC:%.*]] = call <4 x ptr addrspace(1)> @def_vec()
344 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(<4 x ptr addrspace(1)> [[VEC]]) ]
345 ; CHECK-NEXT: [[VEC_RELOCATED:%.*]] = call coldcc <4 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v4p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
346 ; CHECK-NEXT: call void @use_vec(<4 x ptr addrspace(1)> [[VEC_RELOCATED]])
347 ; CHECK-NEXT: ret void
350 %vec = call <4 x ptr addrspace(1)> @def_vec()
351 call void @do_safepoint() [ "deopt"() ]
352 call void @use_vec(<4 x ptr addrspace(1)> %vec)