1 ; RUN: opt -S -passes=indvars < %s | FileCheck %s
3 declare void @side_effect(i1)
5 define void @latch_dominating_0(i8 %start) {
6 ; CHECK-LABEL: latch_dominating_0
8 %e = icmp slt i8 %start, 42
9 br i1 %e, label %loop, label %exit
13 %idx = phi i8 [ %start, %entry ], [ %idx.inc, %be ]
14 %idx.inc = add i8 %idx, 1
15 %folds.to.true = icmp slt i8 %idx, 42
16 ; CHECK: call void @side_effect(i1 true)
17 call void @side_effect(i1 %folds.to.true)
18 %c0 = icmp slt i8 %idx.inc, 42
19 br i1 %c0, label %be, label %exit
22 ; CHECK: call void @side_effect(i1 true)
23 call void @side_effect(i1 %folds.to.true)
24 %c1 = icmp slt i8 %idx.inc, 100
25 br i1 %c1, label %loop, label %exit
31 define void @latch_dominating_1(i8 %start) {
32 ; CHECK-LABEL: latch_dominating_1
34 %e = icmp slt i8 %start, 42
35 br i1 %e, label %loop, label %exit
39 %idx = phi i8 [ %start, %entry ], [ %idx.inc, %be ]
40 %idx.inc = add i8 %idx, 1
41 %does.not.fold.to.true = icmp slt i8 %idx, 42
42 ; CHECK: call void @side_effect(i1 %does.not.fold.to.true)
43 call void @side_effect(i1 %does.not.fold.to.true)
44 %c0 = icmp slt i8 %idx.inc, 42
45 br i1 %c0, label %be, label %be
48 ; CHECK: call void @side_effect(i1 %does.not.fold.to.true)
49 call void @side_effect(i1 %does.not.fold.to.true)
50 %c1 = icmp slt i8 %idx.inc, 100
51 br i1 %c1, label %loop, label %exit