blob: 83394628cc4470fb9e006e39d51adf6919760e66 [file] [log] [blame]
Dan Gohman3c7d3082009-09-11 18:01:28 +00001; RUN: opt < %s -simplifycfg -S | \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002; RUN: not grep {icmp eq}
3
4; Check that simplifycfg deletes a dead 'seteq' instruction when it
5; folds a conditional branch into a switch instruction.
6
Tanya Lattnerb46665e2008-03-18 03:45:45 +00007declare void @foo()
Dan Gohmanf17a25c2007-07-18 16:29:46 +00008
Tanya Lattnerb46665e2008-03-18 03:45:45 +00009declare void @bar()
10
11define void @testcfg(i32 %V) {
12 %C = icmp eq i32 %V, 18 ; <i1> [#uses=1]
13 %D = icmp eq i32 %V, 180 ; <i1> [#uses=1]
14 %E = or i1 %C, %D ; <i1> [#uses=1]
15 br i1 %E, label %L1, label %Sw
16Sw: ; preds = %0
17 switch i32 %V, label %L1 [
18 i32 15, label %L2
19 i32 16, label %L2
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020 ]
Tanya Lattnerb46665e2008-03-18 03:45:45 +000021L1: ; preds = %Sw, %0
22 call void @foo( )
23 ret void
24L2: ; preds = %Sw, %Sw
25 call void @bar( )
26 ret void
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027}
28