1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=loop-unroll-full -unroll-full-max-count=1 %s | FileCheck %s
4 @GlobIntONE = global i32 0, align 4
6 ; Make sure we don't reuse the phi (undef, X) for X.
9 ; CHECK-LABEL: define ptr @test() {
10 ; CHECK-NEXT: [[ENTRY:.*:]]
11 ; CHECK-NEXT: br label %[[FOR_BODY_PEEL_BEGIN:.*]]
12 ; CHECK: [[FOR_BODY_PEEL_BEGIN]]:
13 ; CHECK-NEXT: br label %[[FOR_BODY_PEEL:.*]]
14 ; CHECK: [[FOR_BODY_PEEL]]:
15 ; CHECK-NEXT: br i1 true, label %[[CLEANUP_PEEL:.*]], label %[[CLEANUP_LOOPEXIT_PEEL:.*]]
16 ; CHECK: [[CLEANUP_LOOPEXIT_PEEL]]:
17 ; CHECK-NEXT: br label %[[CLEANUP_PEEL]]
18 ; CHECK: [[CLEANUP_PEEL]]:
19 ; CHECK-NEXT: [[RETVAL_2_PEEL:%.*]] = phi ptr [ undef, %[[FOR_BODY_PEEL]] ], [ @GlobIntONE, %[[CLEANUP_LOOPEXIT_PEEL]] ]
20 ; CHECK-NEXT: br i1 true, label %[[FOR_BODY_PEEL_NEXT:.*]], label %[[CLEANUP2:.*]]
21 ; CHECK: [[FOR_BODY_PEEL_NEXT]]:
22 ; CHECK-NEXT: br label %[[FOR_BODY_PEEL_NEXT1:.*]]
23 ; CHECK: [[FOR_BODY_PEEL_NEXT1]]:
24 ; CHECK-NEXT: br label %[[ENTRY_PEEL_NEWPH:.*]]
25 ; CHECK: [[ENTRY_PEEL_NEWPH]]:
26 ; CHECK-NEXT: br label %[[FOR_BODY:.*]]
27 ; CHECK: [[FOR_BODY]]:
28 ; CHECK-NEXT: br i1 false, label %[[CLEANUP:.*]], label %[[CLEANUP_LOOPEXIT:.*]]
29 ; CHECK: [[CLEANUP_LOOPEXIT]]:
30 ; CHECK-NEXT: br label %[[CLEANUP]]
32 ; CHECK-NEXT: br i1 false, label %[[FOR_BODY]], label %[[CLEANUP2_LOOPEXIT:.*]], !llvm.loop [[LOOP0:![0-9]+]]
33 ; CHECK: [[CLEANUP2_LOOPEXIT]]:
34 ; CHECK-NEXT: [[RETVAL_2_LCSSA_PH:%.*]] = phi ptr [ @GlobIntONE, %[[CLEANUP]] ]
35 ; CHECK-NEXT: br label %[[CLEANUP2]]
36 ; CHECK: [[CLEANUP2]]:
37 ; CHECK-NEXT: [[RETVAL_2_LCSSA:%.*]] = phi ptr [ [[RETVAL_2_PEEL]], %[[CLEANUP_PEEL]] ], [ [[RETVAL_2_LCSSA_PH]], %[[CLEANUP2_LOOPEXIT]] ]
38 ; CHECK-NEXT: ret ptr [[RETVAL_2_LCSSA]]
44 %retval.0 = phi ptr [ undef, %entry ], [ %retval.2, %cleanup ]
45 %cmp1.not = phi i1 [ true, %entry ], [ false, %cleanup ]
46 br i1 %cmp1.not, label %cleanup, label %cleanup.loopexit
52 %retval.2 = phi ptr [ %retval.0, %for.body ], [ @GlobIntONE, %cleanup.loopexit ]
53 br i1 %cmp1.not, label %for.body, label %cleanup2
56 %retval.2.lcssa = phi ptr [ %retval.2, %cleanup ]
57 ret ptr %retval.2.lcssa
60 ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]]}
61 ; CHECK: [[META1]] = !{!"llvm.loop.peeled.count", i32 1}