Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: tests_lit/llvm2ice_tests/switch-opt.ll

Issue 1213593002: Implement ARM32 switch lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 | FileCheck %s 5 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 | FileCheck %s
6 6
7 ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --assemble \
8 ; RUN: --disassemble --target arm32 -i %s --args -Om1 --skip-unimplemented \
jvoung (off chromium) 2015/06/25 21:24:50 Can you leave a "TODO(jvoung): to switch this to O
ascull 2015/06/29 17:00:03 Done.
9 ; RUN: | %if --need=target_ARM32 --command FileCheck --check-prefix ARM32 %s
10
7 define i32 @testSwitch(i32 %a) { 11 define i32 @testSwitch(i32 %a) {
8 entry: 12 entry:
9 switch i32 %a, label %sw.default [ 13 switch i32 %a, label %sw.default [
10 i32 1, label %sw.epilog 14 i32 1, label %sw.epilog
11 i32 2, label %sw.epilog 15 i32 2, label %sw.epilog
12 i32 3, label %sw.epilog 16 i32 3, label %sw.epilog
13 i32 7, label %sw.bb1 17 i32 7, label %sw.bb1
14 i32 8, label %sw.bb1 18 i32 8, label %sw.bb1
15 i32 15, label %sw.bb2 19 i32 15, label %sw.bb2
16 i32 14, label %sw.bb2 20 i32 14, label %sw.bb2
(...skipping 25 matching lines...) Expand all
42 switch i32 10, label %sw.default [ 46 switch i32 10, label %sw.default [
43 i32 1, label %sw.default 47 i32 1, label %sw.default
44 ] 48 ]
45 49
46 sw.default: 50 sw.default:
47 ret i32 20 51 ret i32 20
48 } 52 }
49 ; CHECK-LABEL: testSwitchImm 53 ; CHECK-LABEL: testSwitchImm
50 ; CHECK-NOT: cmp 0x{{[0-9a-f]*}}, 54 ; CHECK-NOT: cmp 0x{{[0-9a-f]*}},
51 55
56 ; ARM32-LABEL: testSwitchImm
57 ; ARM32: cmp {{r[0-9]+}}, #1
58 ; ARM32-NEXT: beq
59 ; ARM32-NEXT: b
60
52 ; Test for correct 64-bit lowering. 61 ; Test for correct 64-bit lowering.
53 define internal i32 @testSwitch64(i64 %a) { 62 define internal i32 @testSwitch64(i64 %a) {
54 entry: 63 entry:
55 switch i64 %a, label %sw.default [ 64 switch i64 %a, label %sw.default [
56 i64 123, label %return 65 i64 123, label %return
57 i64 234, label %sw.bb1 66 i64 234, label %sw.bb1
58 i64 345, label %sw.bb2 67 i64 345, label %sw.bb2
59 i64 78187493520, label %sw.bb3 68 i64 78187493520, label %sw.bb3
60 ] 69 ]
61 70
(...skipping 24 matching lines...) Expand all
86 ; CHECK-NEXT: je 95 ; CHECK-NEXT: je
87 ; CHECK: cmp {{.*}},0x159 96 ; CHECK: cmp {{.*}},0x159
88 ; CHECK-NEXT: jne 97 ; CHECK-NEXT: jne
89 ; CHECK-NEXT: cmp {{.*}},0x0 98 ; CHECK-NEXT: cmp {{.*}},0x0
90 ; CHECK-NEXT: je 99 ; CHECK-NEXT: je
91 ; CHECK: cmp {{.*}},0x34567890 100 ; CHECK: cmp {{.*}},0x34567890
92 ; CHECK-NEXT: jne 101 ; CHECK-NEXT: jne
93 ; CHECK-NEXT: cmp {{.*}},0x12 102 ; CHECK-NEXT: cmp {{.*}},0x12
94 ; CHECK-NEXT: je 103 ; CHECK-NEXT: je
95 104
105 ; ARM32-LABEL: testSwitch64
106 ; ARM32: cmp {{r[0-9]+}}, #123
107 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #0
108 ; ARM32-NEXT: beq
109 ; ARM32: cmp {{r[0-9]+}}, #234
110 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #0
111 ; ARM32-NEXT: beq
112 ; ARM32: movw [[REG:r[0-9]+]], #345
113 ; ARM32-NEXT: cmp {{r[0-9]+}}, [[REG]]
114 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #0
115 ; ARM32-NEXT: beq
116 ; ARM32: movw [[REG:r[0-9]+]], #30864
117 ; ARM32-NEXT: movt [[REG]], #13398
118 ; ARM32-NEXT: cmp {{r[0-9]+}}, [[REG]]
119 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #18
120 ; ARM32-NEXT: beq
121 ; ARM32-NEXT: b
122
96 ; Similar to testSwitchImm, make sure proper addressing modes are 123 ; Similar to testSwitchImm, make sure proper addressing modes are
97 ; used. In reality, this is tested by running the output through the 124 ; used. In reality, this is tested by running the output through the
98 ; assembler. 125 ; assembler.
99 define i32 @testSwitchImm64() { 126 define i32 @testSwitchImm64() {
100 entry: 127 entry:
101 switch i64 10, label %sw.default [ 128 switch i64 10, label %sw.default [
102 i64 1, label %sw.default 129 i64 1, label %sw.default
103 ] 130 ]
104 131
105 sw.default: 132 sw.default:
106 ret i32 20 133 ret i32 20
107 } 134 }
108 ; CHECK-LABEL: testSwitchImm64 135 ; CHECK-LABEL: testSwitchImm64
109 ; CHECK: cmp {{.*}},0x1 136 ; CHECK: cmp {{.*}},0x1
110 ; CHECK-NEXT: jne 137 ; CHECK-NEXT: jne
111 ; CHECK-NEXT: cmp {{.*}},0x0 138 ; CHECK-NEXT: cmp {{.*}},0x0
112 ; CHECK-NEXT: je 139 ; CHECK-NEXT: je
140
141 ; ARM32-LABEL: testSwitchImm64
142 ; ARM32: cmp {{r[0-9]+}}, #1
143 ; ARM32-NEXT: cmpeq {{r[0-9]+}}, #0
144 ; ARM32-NEXT: beq [[ADDR:[0-9a-f]+]]
145 ; ARM32-NEXT: b [[ADDR]]
146
OLDNEW
« src/IceTargetLoweringARM32.cpp ('K') | « src/IceTargetLoweringARM32.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698