1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
3 # RUN: llc -O0 -mtriple=mipsel-linux-gnu -relocation-model=pic -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32_PIC
6 define i32 @mod4_0_to_11(i32 %a) {
8 switch i32 %a, label %sw.default [
19 sw.bb: ; preds = %entry, %entry
22 sw.bb1: ; preds = %entry, %entry
25 sw.bb2: ; preds = %entry, %entry
28 sw.bb3: ; preds = %entry, %entry
31 sw.default: ; preds = %entry
34 sw.epilog: ; preds = %sw.default
35 switch i32 %a, label %sw.default8 [
42 sw.bb4: ; preds = %sw.epilog
45 sw.bb5: ; preds = %sw.epilog
48 sw.bb6: ; preds = %sw.epilog
51 sw.bb7: ; preds = %sw.epilog
54 sw.default8: ; preds = %sw.epilog
64 tracksRegLiveness: true
69 blocks: [ '%bb.2', '%bb.3', '%bb.4', '%bb.5', '%bb.2', '%bb.3',
72 blocks: [ '%bb.8', '%bb.9', '%bb.10', '%bb.11' ]
74 ; MIPS32-LABEL: name: mod4_0_to_11
76 ; MIPS32: successors: %bb.6(0x40000000), %bb.1(0x40000000)
77 ; MIPS32: liveins: $a0
78 ; MIPS32: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
79 ; MIPS32: [[ORi:%[0-9]+]]:gpr32 = ORi $zero, 7
80 ; MIPS32: [[ORi1:%[0-9]+]]:gpr32 = ORi $zero, 3
81 ; MIPS32: [[ORi2:%[0-9]+]]:gpr32 = ORi $zero, 2
82 ; MIPS32: [[ORi3:%[0-9]+]]:gpr32 = ORi $zero, 1
83 ; MIPS32: [[ORi4:%[0-9]+]]:gpr32 = ORi $zero, 0
84 ; MIPS32: [[ADDiu:%[0-9]+]]:gpr32 = ADDiu $zero, 65535
85 ; MIPS32: [[ORi5:%[0-9]+]]:gpr32 = ORi $zero, 0
86 ; MIPS32: [[SUBu:%[0-9]+]]:gpr32 = SUBu [[COPY]], [[ORi5]]
87 ; MIPS32: [[SLTu:%[0-9]+]]:gpr32 = SLTu [[ORi]], [[SUBu]]
88 ; MIPS32: [[AND:%[0-9]+]]:gpr32 = AND [[SLTu]], [[ORi3]]
89 ; MIPS32: BNE [[AND]], $zero, %bb.6, implicit-def $at
91 ; MIPS32: successors: %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000), %bb.5(0x20000000)
92 ; MIPS32: [[LUi:%[0-9]+]]:gpr32 = LUi target-flags(mips-abs-hi) %jump-table.0
93 ; MIPS32: [[SLL:%[0-9]+]]:gpr32 = SLL [[SUBu]], 2
94 ; MIPS32: [[ADDu:%[0-9]+]]:gpr32 = ADDu [[LUi]], [[SLL]]
95 ; MIPS32: [[LW:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-abs-lo) %jump-table.0 :: (load 4)
96 ; MIPS32: PseudoIndirectBranch [[LW]]
98 ; MIPS32: $v0 = COPY [[ORi4]]
99 ; MIPS32: RetRA implicit $v0
100 ; MIPS32: bb.3.sw.bb1:
101 ; MIPS32: $v0 = COPY [[ORi3]]
102 ; MIPS32: RetRA implicit $v0
103 ; MIPS32: bb.4.sw.bb2:
104 ; MIPS32: $v0 = COPY [[ORi2]]
105 ; MIPS32: RetRA implicit $v0
106 ; MIPS32: bb.5.sw.bb3:
107 ; MIPS32: $v0 = COPY [[ORi1]]
108 ; MIPS32: RetRA implicit $v0
109 ; MIPS32: bb.6.sw.default:
110 ; MIPS32: successors: %bb.7(0x80000000)
111 ; MIPS32: bb.7.sw.epilog:
112 ; MIPS32: successors: %bb.13(0x40000000), %bb.8(0x40000000)
113 ; MIPS32: [[ORi6:%[0-9]+]]:gpr32 = ORi $zero, 8
114 ; MIPS32: [[SUBu1:%[0-9]+]]:gpr32 = SUBu [[COPY]], [[ORi6]]
115 ; MIPS32: [[SLTu1:%[0-9]+]]:gpr32 = SLTu [[ORi1]], [[SUBu1]]
116 ; MIPS32: [[ORi7:%[0-9]+]]:gpr32 = ORi $zero, 1
117 ; MIPS32: [[AND1:%[0-9]+]]:gpr32 = AND [[SLTu1]], [[ORi7]]
118 ; MIPS32: BNE [[AND1]], $zero, %bb.13, implicit-def $at
119 ; MIPS32: bb.8.sw.epilog:
120 ; MIPS32: successors: %bb.9(0x20000000), %bb.10(0x20000000), %bb.11(0x20000000), %bb.12(0x20000000)
121 ; MIPS32: [[LUi1:%[0-9]+]]:gpr32 = LUi target-flags(mips-abs-hi) %jump-table.1
122 ; MIPS32: [[SLL1:%[0-9]+]]:gpr32 = SLL [[SUBu1]], 2
123 ; MIPS32: [[ADDu1:%[0-9]+]]:gpr32 = ADDu [[LUi1]], [[SLL1]]
124 ; MIPS32: [[LW1:%[0-9]+]]:gpr32 = LW [[ADDu1]], target-flags(mips-abs-lo) %jump-table.1 :: (load 4)
125 ; MIPS32: PseudoIndirectBranch [[LW1]]
126 ; MIPS32: bb.9.sw.bb4:
127 ; MIPS32: $v0 = COPY [[ORi4]]
128 ; MIPS32: RetRA implicit $v0
129 ; MIPS32: bb.10.sw.bb5:
130 ; MIPS32: $v0 = COPY [[ORi3]]
131 ; MIPS32: RetRA implicit $v0
132 ; MIPS32: bb.11.sw.bb6:
133 ; MIPS32: $v0 = COPY [[ORi2]]
134 ; MIPS32: RetRA implicit $v0
135 ; MIPS32: bb.12.sw.bb7:
136 ; MIPS32: $v0 = COPY [[ORi1]]
137 ; MIPS32: RetRA implicit $v0
138 ; MIPS32: bb.13.sw.default8:
139 ; MIPS32: $v0 = COPY [[ADDiu]]
140 ; MIPS32: RetRA implicit $v0
141 ; MIPS32_PIC-LABEL: name: mod4_0_to_11
142 ; MIPS32_PIC: bb.0.entry:
143 ; MIPS32_PIC: successors: %bb.6(0x40000000), %bb.1(0x40000000)
144 ; MIPS32_PIC: liveins: $a0, $t9, $v0
145 ; MIPS32_PIC: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t9
146 ; MIPS32_PIC: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
147 ; MIPS32_PIC: [[ORi:%[0-9]+]]:gpr32 = ORi $zero, 7
148 ; MIPS32_PIC: [[ORi1:%[0-9]+]]:gpr32 = ORi $zero, 3
149 ; MIPS32_PIC: [[ORi2:%[0-9]+]]:gpr32 = ORi $zero, 2
150 ; MIPS32_PIC: [[ORi3:%[0-9]+]]:gpr32 = ORi $zero, 1
151 ; MIPS32_PIC: [[ORi4:%[0-9]+]]:gpr32 = ORi $zero, 0
152 ; MIPS32_PIC: [[ADDiu:%[0-9]+]]:gpr32 = ADDiu $zero, 65535
153 ; MIPS32_PIC: [[ORi5:%[0-9]+]]:gpr32 = ORi $zero, 0
154 ; MIPS32_PIC: [[SUBu:%[0-9]+]]:gpr32 = SUBu [[COPY]], [[ORi5]]
155 ; MIPS32_PIC: [[SLTu:%[0-9]+]]:gpr32 = SLTu [[ORi]], [[SUBu]]
156 ; MIPS32_PIC: [[AND:%[0-9]+]]:gpr32 = AND [[SLTu]], [[ORi3]]
157 ; MIPS32_PIC: BNE [[AND]], $zero, %bb.6, implicit-def $at
158 ; MIPS32_PIC: bb.1.entry:
159 ; MIPS32_PIC: successors: %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000), %bb.5(0x20000000)
160 ; MIPS32_PIC: [[LW:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-got) %jump-table.0 :: (load 4 from got)
161 ; MIPS32_PIC: [[SLL:%[0-9]+]]:gpr32 = SLL [[SUBu]], 2
162 ; MIPS32_PIC: [[ADDu1:%[0-9]+]]:gpr32 = ADDu [[LW]], [[SLL]]
163 ; MIPS32_PIC: [[LW1:%[0-9]+]]:gpr32 = LW [[ADDu1]], target-flags(mips-abs-lo) %jump-table.0 :: (load 4)
164 ; MIPS32_PIC: [[ADDu2:%[0-9]+]]:gpr32 = ADDu [[LW1]], [[ADDu]]
165 ; MIPS32_PIC: PseudoIndirectBranch [[ADDu2]]
166 ; MIPS32_PIC: bb.2.sw.bb:
167 ; MIPS32_PIC: $v0 = COPY [[ORi4]]
168 ; MIPS32_PIC: RetRA implicit $v0
169 ; MIPS32_PIC: bb.3.sw.bb1:
170 ; MIPS32_PIC: $v0 = COPY [[ORi3]]
171 ; MIPS32_PIC: RetRA implicit $v0
172 ; MIPS32_PIC: bb.4.sw.bb2:
173 ; MIPS32_PIC: $v0 = COPY [[ORi2]]
174 ; MIPS32_PIC: RetRA implicit $v0
175 ; MIPS32_PIC: bb.5.sw.bb3:
176 ; MIPS32_PIC: $v0 = COPY [[ORi1]]
177 ; MIPS32_PIC: RetRA implicit $v0
178 ; MIPS32_PIC: bb.6.sw.default:
179 ; MIPS32_PIC: successors: %bb.7(0x80000000)
180 ; MIPS32_PIC: bb.7.sw.epilog:
181 ; MIPS32_PIC: successors: %bb.13(0x40000000), %bb.8(0x40000000)
182 ; MIPS32_PIC: [[ORi6:%[0-9]+]]:gpr32 = ORi $zero, 8
183 ; MIPS32_PIC: [[SUBu1:%[0-9]+]]:gpr32 = SUBu [[COPY]], [[ORi6]]
184 ; MIPS32_PIC: [[SLTu1:%[0-9]+]]:gpr32 = SLTu [[ORi1]], [[SUBu1]]
185 ; MIPS32_PIC: [[ORi7:%[0-9]+]]:gpr32 = ORi $zero, 1
186 ; MIPS32_PIC: [[AND1:%[0-9]+]]:gpr32 = AND [[SLTu1]], [[ORi7]]
187 ; MIPS32_PIC: BNE [[AND1]], $zero, %bb.13, implicit-def $at
188 ; MIPS32_PIC: bb.8.sw.epilog:
189 ; MIPS32_PIC: successors: %bb.9(0x20000000), %bb.10(0x20000000), %bb.11(0x20000000), %bb.12(0x20000000)
190 ; MIPS32_PIC: [[LW2:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-got) %jump-table.1 :: (load 4 from got)
191 ; MIPS32_PIC: [[SLL1:%[0-9]+]]:gpr32 = SLL [[SUBu1]], 2
192 ; MIPS32_PIC: [[ADDu3:%[0-9]+]]:gpr32 = ADDu [[LW2]], [[SLL1]]
193 ; MIPS32_PIC: [[LW3:%[0-9]+]]:gpr32 = LW [[ADDu3]], target-flags(mips-abs-lo) %jump-table.1 :: (load 4)
194 ; MIPS32_PIC: [[ADDu4:%[0-9]+]]:gpr32 = ADDu [[LW3]], [[ADDu]]
195 ; MIPS32_PIC: PseudoIndirectBranch [[ADDu4]]
196 ; MIPS32_PIC: bb.9.sw.bb4:
197 ; MIPS32_PIC: $v0 = COPY [[ORi4]]
198 ; MIPS32_PIC: RetRA implicit $v0
199 ; MIPS32_PIC: bb.10.sw.bb5:
200 ; MIPS32_PIC: $v0 = COPY [[ORi3]]
201 ; MIPS32_PIC: RetRA implicit $v0
202 ; MIPS32_PIC: bb.11.sw.bb6:
203 ; MIPS32_PIC: $v0 = COPY [[ORi2]]
204 ; MIPS32_PIC: RetRA implicit $v0
205 ; MIPS32_PIC: bb.12.sw.bb7:
206 ; MIPS32_PIC: $v0 = COPY [[ORi1]]
207 ; MIPS32_PIC: RetRA implicit $v0
208 ; MIPS32_PIC: bb.13.sw.default8:
209 ; MIPS32_PIC: $v0 = COPY [[ADDiu]]
210 ; MIPS32_PIC: RetRA implicit $v0
214 %0:gprb(s32) = COPY $a0
215 %4:gprb(s32) = G_CONSTANT i32 7
216 %8:gprb(s32) = G_CONSTANT i32 3
217 %9:gprb(s32) = G_CONSTANT i32 2
218 %10:gprb(s32) = G_CONSTANT i32 1
219 %11:gprb(s32) = G_CONSTANT i32 0
220 %18:gprb(s32) = G_CONSTANT i32 -1
221 %1:gprb(s32) = G_CONSTANT i32 0
222 %2:gprb(s32) = G_SUB %0, %1
223 %3:gprb(s32) = COPY %2(s32)
224 %5:gprb(s32) = COPY %4(s32)
225 %22:gprb(s32) = G_ICMP intpred(ugt), %3(s32), %5
226 %23:gprb(s32) = COPY %22(s32)
227 %21:gprb(s32) = G_AND %23, %10
228 G_BRCOND %21(s32), %bb.6
231 successors: %bb.2, %bb.3, %bb.4, %bb.5
233 %7:gprb(p0) = G_JUMP_TABLE %jump-table.0
234 G_BRJT %7(p0), %jump-table.0, %3(s32)
255 %12:gprb(s32) = G_CONSTANT i32 8
256 %13:gprb(s32) = G_SUB %0, %12
257 %14:gprb(s32) = COPY %13(s32)
258 %15:gprb(s32) = COPY %8(s32)
259 %20:gprb(s32) = G_ICMP intpred(ugt), %14(s32), %15
260 %24:gprb(s32) = G_CONSTANT i32 1
261 %25:gprb(s32) = COPY %20(s32)
262 %19:gprb(s32) = G_AND %25, %24
263 G_BRCOND %19(s32), %bb.12
266 successors: %bb.8, %bb.9, %bb.10, %bb.11
268 %17:gprb(p0) = G_JUMP_TABLE %jump-table.1
269 G_BRJT %17(p0), %jump-table.1, %14(s32)