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