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