blob: a4c8366e00fbd5a704d37ceba3dea90354f81132 [file] [log] [blame]
Tanya Lattnerf04d8d12008-03-18 03:45:45 +00001; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | \
Reid Spencer9aafdcf2007-04-15 09:21:47 +00002; RUN: not grep {icmp eq}
Chris Lattner72a406e2005-01-01 16:00:56 +00003
4; Check that simplifycfg deletes a dead 'seteq' instruction when it
5; folds a conditional branch into a switch instruction.
6
Tanya Lattnerf04d8d12008-03-18 03:45:45 +00007declare void @foo()
Chris Lattner72a406e2005-01-01 16:00:56 +00008
Tanya Lattnerf04d8d12008-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
Chris Lattner72a406e2005-01-01 16:00:56 +000020 ]
Tanya Lattnerf04d8d12008-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
Chris Lattner72a406e2005-01-01 16:00:56 +000027}
28