Dan Gohman | 3c7d308 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -simplifycfg -S | \ |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2 | ; 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 Lattner | b46665e | 2008-03-18 03:45:45 +0000 | [diff] [blame] | 7 | declare void @foo() |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 8 | |
Tanya Lattner | b46665e | 2008-03-18 03:45:45 +0000 | [diff] [blame] | 9 | declare void @bar() |
| 10 | |
| 11 | define 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 |
| 16 | Sw: ; preds = %0 |
| 17 | switch i32 %V, label %L1 [ |
| 18 | i32 15, label %L2 |
| 19 | i32 16, label %L2 |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 20 | ] |
Tanya Lattner | b46665e | 2008-03-18 03:45:45 +0000 | [diff] [blame] | 21 | L1: ; preds = %Sw, %0 |
| 22 | call void @foo( ) |
| 23 | ret void |
| 24 | L2: ; preds = %Sw, %Sw |
| 25 | call void @bar( ) |
| 26 | ret void |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 27 | } |
| 28 | |