1*cee313d2SEric Christopher; RUN: opt < %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
2*cee313d2SEric Christopher; RUN: opt < %s -passes=rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
3*cee313d2SEric Christopher
4*cee313d2SEric Christopher
5*cee313d2SEric Christopherdeclare i1 @runtime_value() "gc-leaf-function"
6*cee313d2SEric Christopher
7*cee313d2SEric Christopherdeclare void @do_safepoint()
8*cee313d2SEric Christopher
9*cee313d2SEric Christopherdefine void @select_of_phi(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* %base_obj_y) gc "statepoint-example" {
10*cee313d2SEric Christopherentry:
11*cee313d2SEric Christopher  br label %loop
12*cee313d2SEric Christopher
13*cee313d2SEric Christopherloop:                                             ; preds = %merge, %entry
14*cee313d2SEric Christopher  %current_x = phi i64 addrspace(1)* [ %base_obj_x, %entry ], [ %next_x, %merge ]
15*cee313d2SEric Christopher  %current_y = phi i64 addrspace(1)* [ %base_obj_y, %entry ], [ %next_y, %merge ]
16*cee313d2SEric Christopher  %current = phi i64 addrspace(1)* [ null, %entry ], [ %next, %merge ]
17*cee313d2SEric Christopher  %condition = call i1 @runtime_value()
18*cee313d2SEric Christopher  %next_x = getelementptr i64, i64 addrspace(1)* %current_x, i32 1
19*cee313d2SEric Christopher  %next_y = getelementptr i64, i64 addrspace(1)* %current_y, i32 1
20*cee313d2SEric Christopher  br i1 %condition, label %true, label %false
21*cee313d2SEric Christopher
22*cee313d2SEric Christophertrue:                                             ; preds = %loop
23*cee313d2SEric Christopher  br label %merge
24*cee313d2SEric Christopher
25*cee313d2SEric Christopherfalse:                                            ; preds = %loop
26*cee313d2SEric Christopher  br label %merge
27*cee313d2SEric Christopher
28*cee313d2SEric Christophermerge:                                            ; preds = %false, %true
29*cee313d2SEric Christopher  %next = phi i64 addrspace(1)* [ %next_x, %true ], [ %next_y, %false ]
30*cee313d2SEric Christopher  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
31*cee313d2SEric Christopher  br label %loop
32*cee313d2SEric Christopher}
33*cee313d2SEric Christopher; CHECK: Base Pairs (w/o Relocation):
34*cee313d2SEric Christopher; CHECK-DAG: derived %next base %next.base
35*cee313d2SEric Christopher; CHECK-DAG: derived %next_x base %base_obj_x
36*cee313d2SEric Christopher; CHECK-DAG: derived %next_y base %base_obj_y
37