1; RUN: opt < %s -indvars -S | FileCheck %s
2target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3
4; CHECK-LABEL: @foo
5define void @foo() {
6entry:
7  br label %L1_header
8
9L1_header:
10  br label %L2_header
11
12; CHECK: L2_header:
13; CHECK: %[[INDVAR:.*]] = phi i64
14; CHECK: %[[TRUNC:.*]] = trunc i64 %[[INDVAR]] to i32
15L2_header:
16  %i = phi i32 [ 0, %L1_header ], [ %i_next, %L2_latch ]
17  %i_prom = sext i32 %i to i64
18  br label %L3_header
19
20L3_header:
21  br i1 undef, label %L3_latch, label %L2_exiting_1
22
23L3_latch:
24  br i1 undef, label %L3_header, label %L2_exiting_2
25
26L2_exiting_1:
27  br i1 undef, label %L2_latch, label %L1_latch
28
29L2_exiting_2:
30  br i1 undef, label %L2_latch, label %L1_latch
31
32L2_latch:
33  %i_next = add nsw i32 %i, 1
34  br label %L2_header
35
36L1_latch:
37; CHECK: L1_latch:
38; CHECK: %i_lcssa = phi i32 [ %[[TRUNC]], %L2_exiting_1 ], [ %[[TRUNC]], %L2_exiting_2 ]
39
40  %i_lcssa = phi i32 [ %i, %L2_exiting_1 ], [ %i, %L2_exiting_2 ]
41  br i1 undef, label %exit, label %L1_header
42
43exit:
44  ret void
45}
46