1c6ec563fSPhilip Reames; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2cee313d2SEric Christopher; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck  %s
3cee313d2SEric Christopher; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck  %s
4cee313d2SEric Christopher
5cee313d2SEric Christopher
6cee313d2SEric Christopherdefine i64 addrspace(1)* @test(<2 x i64 addrspace(1)*> %vec, i32 %idx) gc "statepoint-example" {
7cee313d2SEric Christopher; Note that the second extractelement is actually redundant here.  A correct output would
8cee313d2SEric Christopher; be to reuse the existing obj as a base since it is actually a base pointer.
9c6ec563fSPhilip Reames; CHECK-LABEL: @test(
10c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
11*5cabf472SPhilip Reames; CHECK-NEXT:    [[OBJ:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC:%.*]], i32 [[IDX:%.*]]
12*5cabf472SPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i64 addrspace(1)* [[OBJ]]) ]
13*5cabf472SPhilip Reames; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
14c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJ_RELOCATED]] to i64 addrspace(1)*
15c6ec563fSPhilip Reames; CHECK-NEXT:    ret i64 addrspace(1)* [[OBJ_RELOCATED_CASTED]]
16c6ec563fSPhilip Reames;
17cee313d2SEric Christopherentry:
18cee313d2SEric Christopher  %obj = extractelement <2 x i64 addrspace(1)*> %vec, i32 %idx
19cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"() ]
20cee313d2SEric Christopher  ret i64 addrspace(1)* %obj
21cee313d2SEric Christopher}
22cee313d2SEric Christopher
23cee313d2SEric Christopherdefine i64 addrspace(1)* @test2(<2 x i64 addrspace(1)*>* %ptr, i1 %cnd, i32 %idx1, i32 %idx2) gc "statepoint-example" {
24c6ec563fSPhilip Reames; CHECK-LABEL: @test2(
25c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
26c6ec563fSPhilip Reames; CHECK-NEXT:    br i1 [[CND:%.*]], label [[TAKEN:%.*]], label [[UNTAKEN:%.*]]
27c6ec563fSPhilip Reames; CHECK:       taken:
28c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJA:%.*]] = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* [[PTR:%.*]], align 16
29c6ec563fSPhilip Reames; CHECK-NEXT:    br label [[MERGE:%.*]]
30c6ec563fSPhilip Reames; CHECK:       untaken:
31c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJB:%.*]] = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* [[PTR]], align 16
32c6ec563fSPhilip Reames; CHECK-NEXT:    br label [[MERGE]]
33c6ec563fSPhilip Reames; CHECK:       merge:
34c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = phi <2 x i64 addrspace(1)*> [ [[OBJA]], [[TAKEN]] ], [ [[OBJB]], [[UNTAKEN]] ]
35c6ec563fSPhilip Reames; CHECK-NEXT:    br i1 [[CND]], label [[TAKEN2:%.*]], label [[UNTAKEN2:%.*]]
36c6ec563fSPhilip Reames; CHECK:       taken2:
37*5cabf472SPhilip Reames; CHECK-NEXT:    [[OBJ0:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC]], i32 [[IDX1:%.*]]
38c6ec563fSPhilip Reames; CHECK-NEXT:    br label [[MERGE2:%.*]]
39c6ec563fSPhilip Reames; CHECK:       untaken2:
40*5cabf472SPhilip Reames; CHECK-NEXT:    [[OBJ1:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC]], i32 [[IDX2:%.*]]
41c6ec563fSPhilip Reames; CHECK-NEXT:    br label [[MERGE2]]
42c6ec563fSPhilip Reames; CHECK:       merge2:
43c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ:%.*]] = phi i64 addrspace(1)* [ [[OBJ0]], [[TAKEN2]] ], [ [[OBJ1]], [[UNTAKEN2]] ]
44*5cabf472SPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i64 addrspace(1)* [[OBJ]]) ]
45*5cabf472SPhilip Reames; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
46c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJ_RELOCATED]] to i64 addrspace(1)*
47c6ec563fSPhilip Reames; CHECK-NEXT:    ret i64 addrspace(1)* [[OBJ_RELOCATED_CASTED]]
48c6ec563fSPhilip Reames;
49cee313d2SEric Christopherentry:
50cee313d2SEric Christopher  br i1 %cnd, label %taken, label %untaken
51cee313d2SEric Christopher
52cee313d2SEric Christophertaken:                                            ; preds = %entry
53cee313d2SEric Christopher  %obja = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
54cee313d2SEric Christopher  br label %merge
55cee313d2SEric Christopher
56cee313d2SEric Christopheruntaken:                                          ; preds = %entry
57cee313d2SEric Christopher  %objb = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
58cee313d2SEric Christopher  br label %merge
59cee313d2SEric Christopher
60cee313d2SEric Christophermerge:                                            ; preds = %untaken, %taken
61cee313d2SEric Christopher  %vec = phi <2 x i64 addrspace(1)*> [ %obja, %taken ], [ %objb, %untaken ]
62cee313d2SEric Christopher  br i1 %cnd, label %taken2, label %untaken2
63cee313d2SEric Christopher
64cee313d2SEric Christophertaken2:                                           ; preds = %merge
65cee313d2SEric Christopher  %obj0 = extractelement <2 x i64 addrspace(1)*> %vec, i32 %idx1
66cee313d2SEric Christopher  br label %merge2
67cee313d2SEric Christopher
68cee313d2SEric Christopheruntaken2:                                         ; preds = %merge
69cee313d2SEric Christopher  %obj1 = extractelement <2 x i64 addrspace(1)*> %vec, i32 %idx2
70cee313d2SEric Christopher  br label %merge2
71cee313d2SEric Christopher
72cee313d2SEric Christophermerge2:                                           ; preds = %untaken2, %taken2
73cee313d2SEric Christopher  %obj = phi i64 addrspace(1)* [ %obj0, %taken2 ], [ %obj1, %untaken2 ]
74cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"() ]
75cee313d2SEric Christopher  ret i64 addrspace(1)* %obj
76cee313d2SEric Christopher}
77cee313d2SEric Christopher
78cee313d2SEric Christopherdefine i64 addrspace(1)* @test3(i64 addrspace(1)* %ptr) gc "statepoint-example" {
79c6ec563fSPhilip Reames; CHECK-LABEL: @test3(
80c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
81c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[PTR:%.*]], i32 0, !is_base_value !0
82c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[PTR]], i32 0
83c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_BASE:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC_BASE]], i32 0, !is_base_value !0
84c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC]], i32 0
85c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i64 addrspace(1)* [[OBJ]], i64 addrspace(1)* [[OBJ_BASE]]) ]
86c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
87c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJ_RELOCATED]] to i64 addrspace(1)*
88c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
89c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJ_BASE_RELOCATED]] to i64 addrspace(1)*
90c6ec563fSPhilip Reames; CHECK-NEXT:    ret i64 addrspace(1)* [[OBJ_RELOCATED_CASTED]]
91c6ec563fSPhilip Reames;
92cee313d2SEric Christopherentry:
93cee313d2SEric Christopher  %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %ptr, i32 0
94cee313d2SEric Christopher  %obj = extractelement <2 x i64 addrspace(1)*> %vec, i32 0
95cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"() ]
96cee313d2SEric Christopher  ret i64 addrspace(1)* %obj
97cee313d2SEric Christopher}
98cee313d2SEric Christopher
99cee313d2SEric Christopherdefine i64 addrspace(1)* @test4(i64 addrspace(1)* %ptr) gc "statepoint-example" {
100cee313d2SEric Christopher; When we can optimize an extractelement from a known
101cee313d2SEric Christopher; index and avoid introducing new base pointer instructions
102c6ec563fSPhilip Reames; CHECK-LABEL: @test4(
103c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
104c6ec563fSPhilip Reames; CHECK-NEXT:    [[DERIVED:%.*]] = getelementptr i64, i64 addrspace(1)* [[PTR:%.*]], i64 16
105c6ec563fSPhilip Reames; CHECK-NEXT:    [[VECA_BASE:%.*]] = insertelement <2 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[PTR]], i32 0, !is_base_value !0
106c6ec563fSPhilip Reames; CHECK-NEXT:    [[VECA:%.*]] = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[DERIVED]], i32 0
107c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x i64 addrspace(1)*> [[VECA_BASE]], i64 addrspace(1)* [[PTR]], i32 1, !is_base_value !0
108c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x i64 addrspace(1)*> [[VECA]], i64 addrspace(1)* [[PTR]], i32 1
109c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_BASE:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC_BASE]], i32 0, !is_base_value !0
110c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC]], i32 0
111c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i64 addrspace(1)* [[OBJ]], i64 addrspace(1)* [[OBJ_BASE]]) ]
112c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
113c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJ_RELOCATED]] to i64 addrspace(1)*
114c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
115c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJ_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJ_BASE_RELOCATED]] to i64 addrspace(1)*
116c6ec563fSPhilip Reames; CHECK-NEXT:    ret i64 addrspace(1)* [[OBJ_RELOCATED_CASTED]]
117c6ec563fSPhilip Reames;
118cee313d2SEric Christopherentry:
119cee313d2SEric Christopher  %derived = getelementptr i64, i64 addrspace(1)* %ptr, i64 16
120cee313d2SEric Christopher  %veca = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %derived, i32 0
121cee313d2SEric Christopher  %vec = insertelement <2 x i64 addrspace(1)*> %veca, i64 addrspace(1)* %ptr, i32 1
122cee313d2SEric Christopher  %obj = extractelement <2 x i64 addrspace(1)*> %vec, i32 0
123cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"() ]
124cee313d2SEric Christopher  ret i64 addrspace(1)* %obj
125cee313d2SEric Christopher}
126cee313d2SEric Christopher
127cee313d2SEric Christopherdeclare void @use(i64 addrspace(1)*) "gc-leaf-function"
128cee313d2SEric Christopherdeclare void @use_vec(<4 x i64 addrspace(1)*>) "gc-leaf-function"
129cee313d2SEric Christopher
130cee313d2SEric Christopherdefine void @test5(i1 %cnd, i64 addrspace(1)* %obj) gc "statepoint-example" {
131cee313d2SEric Christopher; When we fundementally have to duplicate
132c6ec563fSPhilip Reames; CHECK-LABEL: @test5(
133c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
134c6ec563fSPhilip Reames; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i64, i64 addrspace(1)* [[OBJ:%.*]], i64 1
135c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[OBJ]], i32 0, !is_base_value !0
136c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[GEP]], i32 0
137c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC_BASE]], i32 0, !is_base_value !0
138c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC]], i32 0
139c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(i64 addrspace(1)* [[BDV]], i64 addrspace(1)* [[BDV_BASE]]) ]
140c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
141c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_RELOCATED]] to i64 addrspace(1)*
142c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
143c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_BASE_RELOCATED]] to i64 addrspace(1)*
144c6ec563fSPhilip Reames; CHECK-NEXT:    call void @use(i64 addrspace(1)* [[BDV_RELOCATED_CASTED]])
145c6ec563fSPhilip Reames; CHECK-NEXT:    ret void
146c6ec563fSPhilip Reames;
147cee313d2SEric Christopherentry:
148cee313d2SEric Christopher  %gep = getelementptr i64, i64 addrspace(1)* %obj, i64 1
149cee313d2SEric Christopher  %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
150cee313d2SEric Christopher  %bdv = extractelement <2 x i64 addrspace(1)*> %vec, i32 0
151cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
152cee313d2SEric Christopher  call void @use(i64 addrspace(1)* %bdv)
153cee313d2SEric Christopher  ret void
154cee313d2SEric Christopher}
155cee313d2SEric Christopher
156cee313d2SEric Christopherdefine void @test6(i1 %cnd, i64 addrspace(1)* %obj, i64 %idx) gc "statepoint-example" {
157cee313d2SEric Christopher; A more complicated example involving vector and scalar bases.
158cee313d2SEric Christopher; This is derived from a failing test case when we didn't have correct
159cee313d2SEric Christopher; insertelement handling.
160c6ec563fSPhilip Reames; CHECK-LABEL: @test6(
161c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
162c6ec563fSPhilip Reames; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i64, i64 addrspace(1)* [[OBJ:%.*]], i64 1
163c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[OBJ]], i32 0, !is_base_value !0
164c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[GEP]], i32 0
165c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC_BASE]], i64 [[IDX:%.*]], !is_base_value !0
166c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC]], i64 [[IDX]]
167c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(i64 addrspace(1)* [[BDV]], i64 addrspace(1)* [[BDV_BASE]]) ]
168c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
169c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_RELOCATED]] to i64 addrspace(1)*
170c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
171c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_BASE_RELOCATED]] to i64 addrspace(1)*
172c6ec563fSPhilip Reames; CHECK-NEXT:    call void @use(i64 addrspace(1)* [[BDV_RELOCATED_CASTED]])
173c6ec563fSPhilip Reames; CHECK-NEXT:    ret void
174c6ec563fSPhilip Reames;
175cee313d2SEric Christopherentry:
176cee313d2SEric Christopher  %gep = getelementptr i64, i64 addrspace(1)* %obj, i64 1
177cee313d2SEric Christopher  %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
178cee313d2SEric Christopher  %bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
179cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
180cee313d2SEric Christopher  call void @use(i64 addrspace(1)* %bdv)
181cee313d2SEric Christopher  ret void
182cee313d2SEric Christopher}
183cee313d2SEric Christopher
184cee313d2SEric Christopherdefine i64 addrspace(1)* @test7(i1 %cnd, i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2) gc "statepoint-example" {
185c6ec563fSPhilip Reames; CHECK-LABEL: @test7(
186c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
187c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[OBJ2:%.*]], i32 0, !is_base_value !0
188c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[OBJ2]], i32 0
189c6ec563fSPhilip Reames; CHECK-NEXT:    br label [[MERGE1:%.*]]
190c6ec563fSPhilip Reames; CHECK:       merge1:
191c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC2_BASE:%.*]] = phi <2 x i64 addrspace(1)*> [ [[VEC_BASE]], [[ENTRY:%.*]] ], [ [[VEC3_BASE:%.*]], [[MERGE1]] ], !is_base_value !0
192c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC2:%.*]] = phi <2 x i64 addrspace(1)*> [ [[VEC]], [[ENTRY]] ], [ [[VEC3:%.*]], [[MERGE1]] ]
193c6ec563fSPhilip Reames; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i64, i64 addrspace(1)* [[OBJ2]], i64 1
194c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC3_BASE]] = insertelement <2 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[OBJ2]], i32 0, !is_base_value !0
195c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC3]] = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[GEP]], i32 0
196c6ec563fSPhilip Reames; CHECK-NEXT:    br i1 [[CND:%.*]], label [[MERGE1]], label [[NEXT1:%.*]]
197c6ec563fSPhilip Reames; CHECK:       next1:
198c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC2_BASE]], i32 0, !is_base_value !0
199c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC2]], i32 0
200c6ec563fSPhilip Reames; CHECK-NEXT:    br label [[MERGE:%.*]]
201c6ec563fSPhilip Reames; CHECK:       merge:
202c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJB_BASE:%.*]] = phi i64 addrspace(1)* [ [[OBJ:%.*]], [[NEXT1]] ], [ [[BDV_BASE]], [[MERGE]] ], !is_base_value !0
203c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJB:%.*]] = phi i64 addrspace(1)* [ [[OBJ]], [[NEXT1]] ], [ [[BDV]], [[MERGE]] ]
204c6ec563fSPhilip Reames; CHECK-NEXT:    br i1 [[CND]], label [[MERGE]], label [[NEXT:%.*]]
205c6ec563fSPhilip Reames; CHECK:       next:
206c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(i64 addrspace(1)* [[OBJB]], i64 addrspace(1)* [[OBJB_BASE]]) ]
207c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJB_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
208c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJB_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJB_RELOCATED]] to i64 addrspace(1)*
209c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJB_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
210c6ec563fSPhilip Reames; CHECK-NEXT:    [[OBJB_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJB_BASE_RELOCATED]] to i64 addrspace(1)*
211c6ec563fSPhilip Reames; CHECK-NEXT:    ret i64 addrspace(1)* [[OBJB_RELOCATED_CASTED]]
212c6ec563fSPhilip Reames;
213cee313d2SEric Christopherentry:
214cee313d2SEric Christopher  %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %obj2, i32 0
215cee313d2SEric Christopher  br label %merge1
216cee313d2SEric Christopher
217cee313d2SEric Christophermerge1:                                           ; preds = %merge1, %entry
218cee313d2SEric Christopher  %vec2 = phi <2 x i64 addrspace(1)*> [ %vec, %entry ], [ %vec3, %merge1 ]
219cee313d2SEric Christopher  %gep = getelementptr i64, i64 addrspace(1)* %obj2, i64 1
220cee313d2SEric Christopher  %vec3 = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
221cee313d2SEric Christopher  br i1 %cnd, label %merge1, label %next1
222cee313d2SEric Christopher
223cee313d2SEric Christophernext1:                                            ; preds = %merge1
224cee313d2SEric Christopher  %bdv = extractelement <2 x i64 addrspace(1)*> %vec2, i32 0
225cee313d2SEric Christopher  br label %merge
226cee313d2SEric Christopher
227cee313d2SEric Christophermerge:                                            ; preds = %merge, %next1
228cee313d2SEric Christopher  %objb = phi i64 addrspace(1)* [ %obj, %next1 ], [ %bdv, %merge ]
229cee313d2SEric Christopher  br i1 %cnd, label %merge, label %next
230cee313d2SEric Christopher
231cee313d2SEric Christophernext:                                             ; preds = %merge
232cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
233cee313d2SEric Christopher  ret i64 addrspace(1)* %objb
234cee313d2SEric Christopher}
235cee313d2SEric Christopher
236cee313d2SEric Christopher; identify base for shufflevector
237cee313d2SEric Christopherdefine void @test8(i64 addrspace(1)* %obj, i64 %idx) gc "statepoint-example" {
238c6ec563fSPhilip Reames; CHECK-LABEL: @test8(
239c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
240c6ec563fSPhilip Reames; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i64, i64 addrspace(1)* [[OBJ:%.*]], i64 1
241c6ec563fSPhilip Reames; CHECK-NEXT:    [[GEP2:%.*]] = getelementptr i64, i64 addrspace(1)* [[OBJ]], i64 2
242c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC1_BASE:%.*]] = insertelement <4 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[OBJ]], i32 0, !is_base_value !0
243c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC1:%.*]] = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[GEP]], i32 0
244c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC2_BASE:%.*]] = insertelement <4 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[OBJ]], i32 2, !is_base_value !0
245c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC2:%.*]] = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[GEP2]], i32 2
246c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_BASE:%.*]] = shufflevector <4 x i64 addrspace(1)*> [[VEC1_BASE]], <4 x i64 addrspace(1)*> [[VEC2_BASE]], <2 x i32> <i32 0, i32 2>, !is_base_value !0
247c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = shufflevector <4 x i64 addrspace(1)*> [[VEC1]], <4 x i64 addrspace(1)*> [[VEC2]], <2 x i32> <i32 0, i32 2>
248c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC_BASE]], i64 [[IDX:%.*]], !is_base_value !0
249c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC]], i64 [[IDX]]
250c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(i64 addrspace(1)* [[BDV]], i64 addrspace(1)* [[BDV_BASE]]) ]
251c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
252c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_RELOCATED]] to i64 addrspace(1)*
253c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
254c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_BASE_RELOCATED]] to i64 addrspace(1)*
255c6ec563fSPhilip Reames; CHECK-NEXT:    call void @use(i64 addrspace(1)* [[BDV_RELOCATED_CASTED]])
256c6ec563fSPhilip Reames; CHECK-NEXT:    ret void
257c6ec563fSPhilip Reames;
258cee313d2SEric Christopherentry:
259cee313d2SEric Christopher  %gep = getelementptr i64, i64 addrspace(1)* %obj, i64 1
260cee313d2SEric Christopher  %gep2 = getelementptr i64, i64 addrspace(1)* %obj, i64 2
261cee313d2SEric Christopher  %vec1 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep, i32 0
262cee313d2SEric Christopher  %vec2 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %gep2, i32 2
263cee313d2SEric Christopher  %vec = shufflevector <4 x i64 addrspace(1)*> %vec1, <4 x i64 addrspace(1)*> %vec2, <2 x i32> <i32 0, i32 2>
264cee313d2SEric Christopher  %bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
265cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
266cee313d2SEric Christopher  call void @use(i64 addrspace(1)* %bdv)
267cee313d2SEric Christopher  ret void
268cee313d2SEric Christopher}
269cee313d2SEric Christopher
270cee313d2SEric Christopher; Since the same 'base' vector is used in the shuffle operands, we do not need
271cee313d2SEric Christopher; create a shufflevector base.
272cee313d2SEric Christopherdefine void @test9(<4 x i64 addrspace(1)*> %vec1, i64 %idx) gc "statepoint-example" {
273c6ec563fSPhilip Reames; CHECK-LABEL: @test9(
274c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
275c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = shufflevector <4 x i64 addrspace(1)*> [[VEC1:%.*]], <4 x i64 addrspace(1)*> [[VEC1]], <2 x i32> <i32 0, i32 2>
276*5cabf472SPhilip Reames; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x i64 addrspace(1)*> [[VEC]], i64 [[IDX:%.*]]
277*5cabf472SPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(i64 addrspace(1)* [[BDV]]) ]
278*5cabf472SPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
279c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_RELOCATED]] to i64 addrspace(1)*
280c6ec563fSPhilip Reames; CHECK-NEXT:    call void @use(i64 addrspace(1)* [[BDV_RELOCATED_CASTED]])
281c6ec563fSPhilip Reames; CHECK-NEXT:    ret void
282c6ec563fSPhilip Reames;
283cee313d2SEric Christopherentry:
284cee313d2SEric Christopher  ; shrinking vec1 into vec
285cee313d2SEric Christopher  %vec = shufflevector <4 x i64 addrspace(1)*> %vec1, <4 x i64 addrspace(1)*> %vec1, <2 x i32> <i32 0, i32 2>
286cee313d2SEric Christopher  %bdv = extractelement <2 x i64 addrspace(1)*> %vec, i64 %idx
287cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
288cee313d2SEric Christopher  call void @use(i64 addrspace(1)* %bdv)
289cee313d2SEric Christopher  ret void
290cee313d2SEric Christopher}
291cee313d2SEric Christopher
292cee313d2SEric Christopher; vector operand of shufflevector is a phi
293cee313d2SEric Christopherdefine i64 addrspace(1)* @test10(i1 %cnd, i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2) gc "statepoint-example" {
294c6ec563fSPhilip Reames; CHECK-LABEL: @test10(
295c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
296c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC1_BASE:%.*]] = insertelement <4 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[OBJ:%.*]], i32 0, !is_base_value !0
297c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC1:%.*]] = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[OBJ]], i32 0
298c6ec563fSPhilip Reames; CHECK-NEXT:    br i1 [[CND:%.*]], label [[HERE:%.*]], label [[MERGE:%.*]]
299c6ec563fSPhilip Reames; CHECK:       here:
300c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC2_BASE:%.*]] = insertelement <4 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[OBJ2:%.*]], i32 2, !is_base_value !0
301c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC2:%.*]] = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* [[OBJ2]], i32 2
302c6ec563fSPhilip Reames; CHECK-NEXT:    br label [[MERGE]]
303c6ec563fSPhilip Reames; CHECK:       merge:
304c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_BASE:%.*]] = phi <4 x i64 addrspace(1)*> [ [[VEC1_BASE]], [[ENTRY:%.*]] ], [ [[VEC2_BASE]], [[HERE]] ], [ [[VEC3_BASE:%.*]], [[MERGE]] ], !is_base_value !0
305c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = phi <4 x i64 addrspace(1)*> [ [[VEC1]], [[ENTRY]] ], [ [[VEC2]], [[HERE]] ], [ [[VEC3:%.*]], [[MERGE]] ]
306c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC3_BASE]] = shufflevector <4 x i64 addrspace(1)*> [[VEC_BASE]], <4 x i64 addrspace(1)*> [[VEC_BASE]], <4 x i32> <i32 2, i32 0, i32 1, i32 3>, !is_base_value !0
307c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC3]] = shufflevector <4 x i64 addrspace(1)*> [[VEC]], <4 x i64 addrspace(1)*> [[VEC]], <4 x i32> <i32 2, i32 0, i32 1, i32 3>
308c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <4 x i64 addrspace(1)*> [[VEC3_BASE]], i32 0, !is_base_value !0
309c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV:%.*]] = extractelement <4 x i64 addrspace(1)*> [[VEC3]], i32 0
310c6ec563fSPhilip Reames; CHECK-NEXT:    br i1 [[CND]], label [[MERGE]], label [[NEXT:%.*]]
311c6ec563fSPhilip Reames; CHECK:       next:
312c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(i64 addrspace(1)* [[BDV]], i64 addrspace(1)* [[BDV_BASE]]) ]
313c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
314c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_RELOCATED]] to i64 addrspace(1)*
315c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
316c6ec563fSPhilip Reames; CHECK-NEXT:    [[BDV_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BDV_BASE_RELOCATED]] to i64 addrspace(1)*
317c6ec563fSPhilip Reames; CHECK-NEXT:    ret i64 addrspace(1)* [[BDV_RELOCATED_CASTED]]
318c6ec563fSPhilip Reames;
319cee313d2SEric Christopherentry:
320cee313d2SEric Christopher  %vec1 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %obj, i32 0
321cee313d2SEric Christopher  br i1 %cnd, label %here, label %merge
322cee313d2SEric Christopher
323cee313d2SEric Christopherhere:
324cee313d2SEric Christopher  %vec2 = insertelement <4 x i64 addrspace(1)*> undef, i64 addrspace(1)* %obj2, i32 2
325cee313d2SEric Christopher  br label %merge
326cee313d2SEric Christopher
327cee313d2SEric Christophermerge:                                           ; preds = %merge, %entry, %here
328cee313d2SEric Christopher  %vec = phi <4 x i64 addrspace(1)*> [ %vec1, %entry ], [ %vec2, %here], [ %vec3, %merge]
329cee313d2SEric Christopher  %vec3 = shufflevector <4 x i64 addrspace(1)*> %vec, <4 x i64 addrspace(1)*> %vec, <4 x i32> <i32 2, i32 0, i32 1, i32 3>
330cee313d2SEric Christopher  %bdv = extractelement <4 x i64 addrspace(1)*> %vec3, i32 0
331cee313d2SEric Christopher  br i1 %cnd, label %merge, label %next
332cee313d2SEric Christopher
333cee313d2SEric Christophernext:
334cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
335cee313d2SEric Christopher  ret i64 addrspace(1)* %bdv
336cee313d2SEric Christopher}
337cee313d2SEric Christopherdeclare void @do_safepoint()
338cee313d2SEric Christopher
339cee313d2SEric Christopherdefine void @test11(<4 x i64 addrspace(1)*> %vec1) gc "statepoint-example" {
340cee313d2SEric Christopher; CHECK-LABEL: @test11(
341c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
342c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC2:%.*]] = getelementptr i64, <4 x i64 addrspace(1)*> [[VEC1:%.*]], i32 1024
343c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, 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 i64 addrspace(1)*> [[VEC1]]) ]
344c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC1_RELOCATED:%.*]] = call coldcc <4 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v4p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
345c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC1_RELOCATED_CASTED:%.*]] = bitcast <4 x i8 addrspace(1)*> [[VEC1_RELOCATED]] to <4 x i64 addrspace(1)*>
346c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC2_REMAT:%.*]] = getelementptr i64, <4 x i64 addrspace(1)*> [[VEC1_RELOCATED_CASTED]], i32 1024
347c6ec563fSPhilip Reames; CHECK-NEXT:    call void @use_vec(<4 x i64 addrspace(1)*> [[VEC2_REMAT]])
348c6ec563fSPhilip Reames; CHECK-NEXT:    ret void
349c6ec563fSPhilip Reames;
350cee313d2SEric Christopherentry:
351cee313d2SEric Christopher  %vec2 = getelementptr i64, <4 x i64 addrspace(1)*> %vec1, i32 1024
352cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
353cee313d2SEric Christopher  call void @use_vec(<4 x i64 addrspace(1) *> %vec2)
354cee313d2SEric Christopher  ret void
355cee313d2SEric Christopher}
356cee313d2SEric Christopher
357cee313d2SEric Christopherdeclare <4 x i64 addrspace(1)*> @def_vec() "gc-leaf-function"
358cee313d2SEric Christopher
359cee313d2SEric Christopherdefine void @test12(<4 x i64 addrspace(1)*> %vec1) gc "statepoint-example" {
360cee313d2SEric Christopher; CHECK-LABEL: @test12(
361c6ec563fSPhilip Reames; CHECK-NEXT:  entry:
362c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC:%.*]] = call <4 x i64 addrspace(1)*> @def_vec()
363c6ec563fSPhilip Reames; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(<4 x i64 addrspace(1)*> [[VEC]]) ]
364c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_RELOCATED:%.*]] = call coldcc <4 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v4p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
365c6ec563fSPhilip Reames; CHECK-NEXT:    [[VEC_RELOCATED_CASTED:%.*]] = bitcast <4 x i8 addrspace(1)*> [[VEC_RELOCATED]] to <4 x i64 addrspace(1)*>
366c6ec563fSPhilip Reames; CHECK-NEXT:    call void @use_vec(<4 x i64 addrspace(1)*> [[VEC_RELOCATED_CASTED]])
367cee313d2SEric Christopher; CHECK-NEXT:    ret void
368c6ec563fSPhilip Reames;
369cee313d2SEric Christopherentry:
370cee313d2SEric Christopher  %vec = call <4 x i64 addrspace(1)*> @def_vec()
371cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"() ]
372cee313d2SEric Christopher  call void @use_vec(<4 x i64 addrspace(1)*> %vec)
373cee313d2SEric Christopher  ret void
374cee313d2SEric Christopher}
375