1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
3 ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes='require<domtree>,loop(indvars,loop-simplifycfg)' -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
4 ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes=indvars,loop-simplifycfg -verify-memoryssa -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
6 define void @test(i1 %c) {
9 ; CHECK-NEXT: switch i32 0, label [[ENTRY_SPLIT:%.*]] [
10 ; CHECK-NEXT: i32 1, label [[DEAD_EXIT:%.*]]
13 ; CHECK-NEXT: br label [[OUTER:%.*]]
15 ; CHECK-NEXT: br i1 [[C:%.*]], label [[TO_FOLD:%.*]], label [[LATCH:%.*]]
17 ; CHECK-NEXT: br i1 [[C]], label [[LATCH]], label [[INNER_PREHEADER:%.*]]
18 ; CHECK: inner.preheader:
19 ; CHECK-NEXT: br label [[INNER:%.*]]
21 ; CHECK-NEXT: br i1 false, label [[INNER_LATCH:%.*]], label [[UNDEAD:%.*]]
23 ; CHECK-NEXT: br i1 true, label [[INNER]], label [[LATCH_LOOPEXIT:%.*]]
25 ; CHECK-NEXT: br label [[LATCH]]
26 ; CHECK: latch.loopexit:
27 ; CHECK-NEXT: br label [[LATCH]]
29 ; CHECK-NEXT: br label [[OUTER]]
31 ; CHECK-NEXT: ret void
38 br i1 %c, label %to_fold, label %latch
41 br i1 %c, label %latch, label %inner
44 %iv = phi i32 [0, %to_fold], [%iv.next, %inner_latch]
45 %never = icmp sgt i32 %iv, 40
46 br i1 %never, label %inner_latch, label %undead
49 %iv.next = add i32 %iv, 1
50 %cmp = icmp slt i32 %iv.next, 10
51 br i1 %cmp, label %inner, label %latch
57 br i1 true, label %outer, label %dead_exit