OLD | NEW |
1 ; This tests a switch statement, including multiple branches to the | 1 ; This tests a switch statement, including multiple branches to the |
2 ; same label which also results in phi instructions with multiple | 2 ; same label which also results in phi instructions with multiple |
3 ; entries for the same incoming edge. | 3 ; entries for the same incoming edge. |
4 | 4 |
5 ; For x86 see adv-switch-opt.ll | 5 ; For x86 see adv-switch-opt.ll |
6 | 6 |
7 ; TODO(jvoung): Update to -02 once the phi assignments is done for ARM | 7 ; TODO(jvoung): Update to -02 once the phi assignments is done for ARM |
8 ; RUN: %if --need=target_ARM32 --need=allow_dump \ | 8 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
9 ; RUN: --command %p2i --filetype=asm --assemble --disassemble \ | 9 ; RUN: --command %p2i --filetype=asm --assemble --disassemble \ |
10 ; RUN: --target arm32 -i %s --args -Om1 --skip-unimplemented \ | 10 ; RUN: --target arm32 -i %s --args -Om1 --skip-unimplemented \ |
11 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ | 11 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
12 ; RUN: --command FileCheck --check-prefix ARM32 %s | 12 ; RUN: --command FileCheck --check-prefix ARM32 %s |
13 | 13 |
14 define i32 @testSwitch(i32 %a) { | 14 define internal i32 @testSwitch(i32 %a) { |
15 entry: | 15 entry: |
16 switch i32 %a, label %sw.default [ | 16 switch i32 %a, label %sw.default [ |
17 i32 1, label %sw.epilog | 17 i32 1, label %sw.epilog |
18 i32 2, label %sw.epilog | 18 i32 2, label %sw.epilog |
19 i32 3, label %sw.epilog | 19 i32 3, label %sw.epilog |
20 i32 7, label %sw.bb1 | 20 i32 7, label %sw.bb1 |
21 i32 8, label %sw.bb1 | 21 i32 8, label %sw.bb1 |
22 i32 15, label %sw.bb2 | 22 i32 15, label %sw.bb2 |
23 i32 14, label %sw.bb2 | 23 i32 14, label %sw.bb2 |
24 ] | 24 ] |
(...skipping 12 matching lines...) Expand all Loading... |
37 | 37 |
38 sw.epilog: ; preds = %sw.bb2, %sw.default
, %entry, %entry, %entry | 38 sw.epilog: ; preds = %sw.bb2, %sw.default
, %entry, %entry, %entry |
39 %result.1 = phi i32 [ %add, %sw.default ], [ %result.0, %sw.bb2 ], [ 17, %entr
y ], [ 17, %entry ], [ 17, %entry ] | 39 %result.1 = phi i32 [ %add, %sw.default ], [ %result.0, %sw.bb2 ], [ 17, %entr
y ], [ 17, %entry ], [ 17, %entry ] |
40 ret i32 %result.1 | 40 ret i32 %result.1 |
41 } | 41 } |
42 | 42 |
43 ; Check for a valid addressing mode when the switch operand is an | 43 ; Check for a valid addressing mode when the switch operand is an |
44 ; immediate. It's important that there is exactly one case, because | 44 ; immediate. It's important that there is exactly one case, because |
45 ; for two or more cases the source operand is legalized into a | 45 ; for two or more cases the source operand is legalized into a |
46 ; register. | 46 ; register. |
47 define i32 @testSwitchImm() { | 47 define internal i32 @testSwitchImm() { |
48 entry: | 48 entry: |
49 switch i32 10, label %sw.default [ | 49 switch i32 10, label %sw.default [ |
50 i32 1, label %sw.default | 50 i32 1, label %sw.default |
51 ] | 51 ] |
52 | 52 |
53 sw.default: | 53 sw.default: |
54 ret i32 20 | 54 ret i32 20 |
55 } | 55 } |
56 ; ARM32-LABEL: testSwitchImm | 56 ; ARM32-LABEL: testSwitchImm |
57 ; ARM32: cmp {{r[0-9]+}}, #1 | 57 ; ARM32: cmp {{r[0-9]+}}, #1 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 ; ARM32: movw [[REG:r[0-9]+]], #30864 | 98 ; ARM32: movw [[REG:r[0-9]+]], #30864 |
99 ; ARM32-NEXT: movt [[REG]], #13398 | 99 ; ARM32-NEXT: movt [[REG]], #13398 |
100 ; ARM32-NEXT: cmp {{r[0-9]+}}, [[REG]] | 100 ; ARM32-NEXT: cmp {{r[0-9]+}}, [[REG]] |
101 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #18 | 101 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #18 |
102 ; ARM32-NEXT: beq | 102 ; ARM32-NEXT: beq |
103 ; ARM32-NEXT: b | 103 ; ARM32-NEXT: b |
104 | 104 |
105 ; Similar to testSwitchImm, make sure proper addressing modes are | 105 ; Similar to testSwitchImm, make sure proper addressing modes are |
106 ; used. In reality, this is tested by running the output through the | 106 ; used. In reality, this is tested by running the output through the |
107 ; assembler. | 107 ; assembler. |
108 define i32 @testSwitchImm64() { | 108 define internal i32 @testSwitchImm64() { |
109 entry: | 109 entry: |
110 switch i64 10, label %sw.default [ | 110 switch i64 10, label %sw.default [ |
111 i64 1, label %sw.default | 111 i64 1, label %sw.default |
112 ] | 112 ] |
113 | 113 |
114 sw.default: | 114 sw.default: |
115 ret i32 20 | 115 ret i32 20 |
116 } | 116 } |
117 ; ARM32-LABEL: testSwitchImm64 | 117 ; ARM32-LABEL: testSwitchImm64 |
118 ; ARM32: cmp {{r[0-9]+}}, #1 | 118 ; ARM32: cmp {{r[0-9]+}}, #1 |
119 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #0 | 119 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #0 |
120 ; ARM32-NEXT: beq [[ADDR:[0-9a-f]+]] | 120 ; ARM32-NEXT: beq [[ADDR:[0-9a-f]+]] |
121 ; ARM32-NEXT: b [[ADDR]] | 121 ; ARM32-NEXT: b [[ADDR]] |
122 | 122 |
123 define i32 @testSwitchUndef64() { | 123 define internal i32 @testSwitchUndef64() { |
124 entry: | 124 entry: |
125 switch i64 undef, label %sw.default [ | 125 switch i64 undef, label %sw.default [ |
126 i64 1, label %sw.default | 126 i64 1, label %sw.default |
127 ] | 127 ] |
128 | 128 |
129 sw.default: | 129 sw.default: |
130 ret i32 20 | 130 ret i32 20 |
131 } | 131 } |
132 ; ARM32-LABEL: testSwitchUndef64 | 132 ; ARM32-LABEL: testSwitchUndef64 |
133 ; ARM32: movw {{.*}}, #0 | 133 ; ARM32: movw {{.*}}, #0 |
134 ; ARM32: movw {{.*}}, #0 | 134 ; ARM32: movw {{.*}}, #0 |
OLD | NEW |