1 ; RUN: opt -S -indvars < %s | FileCheck %s 2 3 declare void @side_effect(i1) 4 5 define void @latch_dominating_0(i8 %start) { 6 ; CHECK-LABEL: latch_dominating_0 7 entry: 8 %e = icmp slt i8 %start, 42 9 br i1 %e, label %loop, label %exit 10 11 loop: 12 ; CHECK-LABEL: loop 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 20 21 be: 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 26 27 exit: 28 ret void 29 } 30 31 define void @latch_dominating_1(i8 %start) { 32 ; CHECK-LABEL: latch_dominating_1 33 entry: 34 %e = icmp slt i8 %start, 42 35 br i1 %e, label %loop, label %exit 36 37 loop: 38 ; CHECK-LABEL: loop 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 46 47 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 52 53 exit: 54 ret void 55 } 56