1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=indvars -S %s | FileCheck %s
4 define void @test_phi_select() {
5 ; CHECK-LABEL: @test_phi_select(
7 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
9 ; CHECK-NEXT: br i1 false, label [[THEN:%.*]], label [[MERGE:%.*]]
11 ; CHECK-NEXT: br label [[MERGE]]
13 ; CHECK-NEXT: br label [[INNER:%.*]]
15 ; CHECK-NEXT: [[INNER_IV_NEXT:%.*]] = add nsw i64 0, 0
16 ; CHECK-NEXT: br i1 false, label [[INNER]], label [[OUTER_LATCH:%.*]]
18 ; CHECK-NEXT: br i1 true, label [[EXIT:%.*]], label [[OUTER_HEADER]]
20 ; CHECK-NEXT: ret void
23 br label %outer.header
26 %iv = phi i64 [ 0, %entry ], [ %iv.next, %outer.latch ]
27 %iv.next.1 = add nsw i64 %iv, 1
28 %cmp.0 = icmp sgt i64 %iv, 50
29 br i1 %cmp.0, label %then, label %merge
35 %iv.sel = phi i64 [ %iv, %outer.header ], [ %iv.next.1, %then ]
38 inner: ; preds = %inner, %outer.header.new
39 %inner.iv = phi i64 [ %iv.sel, %merge ], [ 0, %inner ]
40 %inner.iv.next = add nsw i64 0, 0
41 %ec.1 = icmp sgt i64 0, 0
42 br i1 %ec.1, label %inner, label %outer.latch
45 %iv.next = add nuw nsw i64 %iv, 1
46 %ec.2 = icmp ult i64 %iv.next, 1000
47 br i1 %ec.2, label %exit, label %outer.header