1; RUN: opt < %s -loop-unswitch -verify-loop-info -S < %s 2>&1 | FileCheck %s 2 3; There are 1 case and 1 default case in the switch. after we unswitch, we know the 4; %a is definitely not 0 in one of the unswitched loop, make sure we take advantage 5; of that and simplify the branches in the loop. 6; 7; CHECK: define void @simplify_with_nonvalness( 8 9; This is the loop in which we know %a is definitely 0. 10; CHECK: sw.bb.us: 11; CHECK: br i1 true, label %if.then.us, label %if.end.us 12 13; This is the loop in which we do not know what %a is but we know %a is definitely NOT 0. 14; Make sure we use that information to simplify. 15; The icmp eq i32 %a, 0 in one of the unswitched loop is simplified to false. 16; CHECK: sw.bb.split: 17; CHECK: br i1 false, label %if.then, label %if.end 18 19define void @simplify_with_nonvalness(i32 %a) #0 { 20entry: 21 br label %for.cond 22 23for.cond: 24 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] 25 %cmp = icmp slt i32 %i.0, 1024 26 br i1 %cmp, label %for.body, label %for.end 27 28for.body: 29 switch i32 %a, label %sw.default [ 30 i32 0, label %sw.bb 31 ] 32 33sw.bb: 34 %cmp1 = icmp eq i32 %a, 0 35 br i1 %cmp1, label %if.then, label %if.end 36 37if.then: 38 call void (...) @bar() 39 br label %if.end 40 41if.end: 42 br label %sw.epilog 43 44sw.default: 45 br label %sw.epilog 46 47sw.epilog: 48 br label %for.inc 49 50for.inc: 51 %inc = add nsw i32 %i.0, 1 52 br label %for.cond 53 54for.end: 55 ret void 56} 57 58declare void @bar(...) 59