Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -lowerswitch -S | FileCheck %s |
| 2 | ; |
| 3 | ; The switch is lowered with a single icmp. |
| 4 | ; CHECK: icmp |
| 5 | ; CHECK-NOT: icmp |
| 6 | ; |
| 7 | ;int foo(int a) { |
| 8 | ; |
| 9 | ; switch (a) { |
| 10 | ; case 0: |
| 11 | ; return 10; |
| 12 | ; case 1: |
| 13 | ; return 3; |
| 14 | ; default: |
| 15 | ; __builtin_unreachable(); |
| 16 | ; } |
| 17 | ; |
| 18 | ;} |
| 19 | |
| 20 | define i32 @foo(i32 %a) { |
| 21 | %1 = alloca i32, align 4 |
| 22 | %2 = alloca i32, align 4 |
| 23 | store i32 %a, i32* %2, align 4 |
| 24 | %3 = load i32, i32* %2, align 4 |
| 25 | switch i32 %3, label %6 [ |
| 26 | i32 0, label %4 |
| 27 | i32 1, label %5 |
| 28 | ] |
| 29 | |
| 30 | ; <label>:4 |
| 31 | store i32 10, i32* %1 |
| 32 | br label %7 |
| 33 | |
| 34 | ; <label>:5 |
| 35 | store i32 3, i32* %1 |
| 36 | br label %7 |
| 37 | |
| 38 | ; <label>:6 |
| 39 | unreachable |
| 40 | |
| 41 | ; <label>:7 |
| 42 | %8 = load i32, i32* %1 |
| 43 | ret i32 %8 |
| 44 | } |