1; RUN: opt -S -licm -loop-guard-widening -licm -debug-pass=Structure < %s 2>&1 | FileCheck %s 2 3; Main point of this test is to check the scheduling -- there should be 4; no analysis passes needed between LICM and LoopGuardWidening 5 6; CHECK: Loop Pass Manager 7; CHECK: Loop Invariant Code Motion 8; CHECK: Widen guards (within a single loop, as a loop pass) 9; CHECK: Loop Invariant Code Motion 10 11declare void @llvm.experimental.guard(i1,...) 12 13define void @iter(i32 %a, i32 %b, i1* %c_p) { 14; CHECK-LABEL @iter 15; CHECK: %cond_0 = icmp ult i32 %a, 10 16; CHECK: %cond_1 = icmp ult i32 %b, 10 17; CHECK: %wide.chk = and i1 %cond_0, %cond_1 18; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ] 19; CHECK-LABEL: loop: 20 21entry: 22 %cond_0 = icmp ult i32 %a, 10 23 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ] 24 br label %loop 25 26loop: ; preds = %loop.preheader, %loop 27 %cond_1 = icmp ult i32 %b, 10 28 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ] 29 %cnd = load i1, i1* %c_p 30 br i1 %cnd, label %loop, label %leave.loopexit 31 32leave.loopexit: ; preds = %loop 33 br label %leave 34 35leave: ; preds = %leave.loopexit, %entry 36 ret void 37} 38 39define void @within_loop(i32 %a, i32 %b, i1* %c_p) { 40; CHECK-LABEL @within_loop 41; CHECK: %cond_0 = icmp ult i32 %a, 10 42; CHECK: %cond_1 = icmp ult i32 %b, 10 43; CHECK: %wide.chk = and i1 %cond_0, %cond_1 44; CHECK-LABEL: loop: 45; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ] 46 47entry: 48 br label %loop 49 50loop: ; preds = %loop.preheader, %loop 51 %cond_0 = icmp ult i32 %a, 10 52 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ] 53 %cond_1 = icmp ult i32 %b, 10 54 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ] 55 %cnd = load i1, i1* %c_p 56 br i1 %cnd, label %loop, label %leave.loopexit 57 58leave.loopexit: ; preds = %loop 59 br label %leave 60 61leave: ; preds = %leave.loopexit, %entry 62 ret void 63} 64 65