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