1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-unroll -verify-loop-lcssa -S < %s | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @b = external local_unnamed_addr global i32, align 4
9 declare i1 @unknown(i32) readonly nounwind willreturn
11 define void @main() local_unnamed_addr #0 {
14 ; CHECK-NEXT: br label [[H1:%.*]]
16 ; CHECK-NEXT: [[D_0:%.*]] = phi i32 [ [[TMP0:%.*]], [[LATCH1:%.*]] ], [ undef, [[PH1:%.*]] ]
17 ; CHECK-NEXT: br label [[PH2:%.*]]
19 ; CHECK-NEXT: br label [[H2:%.*]]
21 ; CHECK-NEXT: br label [[H3:%.*]]
23 ; CHECK-NEXT: [[C1:%.*]] = call i1 @unknown(i32 0)
24 ; CHECK-NEXT: br i1 [[C1]], label [[LATCH3:%.*]], label [[EXIT_LOOPEXIT:%.*]]
26 ; CHECK-NEXT: [[C2:%.*]] = call i1 @unknown(i32 0)
27 ; CHECK-NEXT: br i1 [[C2]], label [[EXIT3:%.*]], label [[H3]]
29 ; CHECK-NEXT: br label [[LATCH2:%.*]]
31 ; CHECK-NEXT: br label [[H3_1:%.*]]
33 ; CHECK-NEXT: [[C1_1:%.*]] = call i1 @unknown(i32 1)
34 ; CHECK-NEXT: br i1 [[C1_1]], label [[LATCH3_1:%.*]], label [[EXIT_LOOPEXIT1:%.*]]
36 ; CHECK-NEXT: [[C2_1:%.*]] = call i1 @unknown(i32 1)
37 ; CHECK-NEXT: br i1 [[C2_1]], label [[EXIT3_1:%.*]], label [[H3_1]]
39 ; CHECK-NEXT: br label [[LATCH2_1:%.*]]
41 ; CHECK-NEXT: [[C3:%.*]] = call i1 @unknown(i32 [[D_0]])
42 ; CHECK-NEXT: br i1 [[C3]], label [[LATCH1]], label [[PH2]]
44 ; CHECK-NEXT: [[TMP0]] = load i32, ptr @b, align 4
45 ; CHECK-NEXT: br label [[H1]]
46 ; CHECK: exit.loopexit:
47 ; CHECK-NEXT: [[D_0_LCSSA_PH:%.*]] = phi i32 [ [[D_0]], [[H3]] ]
48 ; CHECK-NEXT: br label [[EXIT:%.*]]
49 ; CHECK: exit.loopexit1:
50 ; CHECK-NEXT: [[D_0_LCSSA_PH2:%.*]] = phi i32 [ [[D_0]], [[H3_1]] ]
51 ; CHECK-NEXT: br label [[EXIT]]
53 ; CHECK-NEXT: [[D_0_LCSSA:%.*]] = phi i32 [ [[D_0_LCSSA_PH]], [[EXIT_LOOPEXIT]] ], [ [[D_0_LCSSA_PH2]], [[EXIT_LOOPEXIT1]] ]
54 ; CHECK-NEXT: ret void
60 %d.0 = phi i32 [ %1, %latch1 ], [ undef, %ph1 ]
67 %0 = phi i32 [ 0, %ph2 ], [ %inc, %latch2 ]
71 %c1 = call i1 @unknown(i32 %0)
72 br i1 %c1, label %latch3, label %exit
75 %c2 = call i1 @unknown(i32 %0)
76 br i1 %c2, label %exit3, label %h3
82 %inc = add nuw nsw i32 %0, 1
83 %cmp = icmp slt i32 %inc, 2
84 br i1 %cmp, label %h2, label %exit2
87 %c3 = call i1 @unknown(i32 %d.0)
88 br i1 %c3, label %latch1, label %ph2
90 latch1: ; preds = %exit2
91 %1 = load i32, ptr @b, align 4
95 %d.0.lcssa = phi i32 [ %d.0, %h3 ]