1 ; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16 2 3 @t = global i32 10, align 4 4 @f = global i32 199, align 4 5 @a = global i32 1, align 4 6 @b = global i32 10, align 4 7 @c = global i32 1, align 4 8 @z1 = common global i32 0, align 4 9 @z2 = common global i32 0, align 4 10 @z3 = common global i32 0, align 4 11 @z4 = common global i32 0, align 4 12 13 define void @calc_seleq() nounwind { 14 entry: 15 %0 = load i32, i32* @a, align 4 16 %1 = load i32, i32* @b, align 4 17 %cmp = icmp eq i32 %0, %1 18 %2 = load i32, i32* @f, align 4 19 %3 = load i32, i32* @t, align 4 20 %cond = select i1 %cmp, i32 %2, i32 %3 21 store i32 %cond, i32* @z1, align 4 22 ; 16: cmp ${{[0-9]+}}, ${{[0-9]+}} 23 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}} 24 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 25 store i32 %cond, i32* @z2, align 4 26 %4 = load i32, i32* @c, align 4 27 %cmp6 = icmp eq i32 %4, %0 28 %cond10 = select i1 %cmp6, i32 %3, i32 %2 29 store i32 %cond10, i32* @z3, align 4 30 store i32 %cond10, i32* @z4, align 4 31 ret void 32 } 33 34 35 define void @calc_seleqk() nounwind { 36 entry: 37 %0 = load i32, i32* @a, align 4 38 %cmp = icmp eq i32 %0, 1 39 %1 = load i32, i32* @t, align 4 40 %2 = load i32, i32* @f, align 4 41 %cond = select i1 %cmp, i32 %1, i32 %2 42 store i32 %cond, i32* @z1, align 4 43 ; 16: cmpi ${{[0-9]+}}, 1 44 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}} 45 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 46 %cmp1 = icmp eq i32 %0, 10 47 %cond5 = select i1 %cmp1, i32 %2, i32 %1 48 store i32 %cond5, i32* @z2, align 4 49 %3 = load i32, i32* @b, align 4 50 %cmp6 = icmp eq i32 %3, 3 51 %cond10 = select i1 %cmp6, i32 %2, i32 %1 52 store i32 %cond10, i32* @z3, align 4 53 ; 16: cmpi ${{[0-9]+}}, 10 54 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}} 55 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 56 %cmp11 = icmp eq i32 %3, 10 57 %cond15 = select i1 %cmp11, i32 %1, i32 %2 58 store i32 %cond15, i32* @z4, align 4 59 ret void 60 } 61 62 define void @calc_seleqz() nounwind { 63 entry: 64 %0 = load i32, i32* @a, align 4 65 %cmp = icmp eq i32 %0, 0 66 %1 = load i32, i32* @t, align 4 67 %2 = load i32, i32* @f, align 4 68 %cond = select i1 %cmp, i32 %1, i32 %2 69 store i32 %cond, i32* @z1, align 4 70 ; 16: beqz ${{[0-9]+}}, $BB{{[0-9]+}}_{{[0-9]}} 71 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 72 %3 = load i32, i32* @b, align 4 73 %cmp1 = icmp eq i32 %3, 0 74 %cond5 = select i1 %cmp1, i32 %2, i32 %1 75 store i32 %cond5, i32* @z2, align 4 76 %4 = load i32, i32* @c, align 4 77 %cmp6 = icmp eq i32 %4, 0 78 %cond10 = select i1 %cmp6, i32 %1, i32 %2 79 store i32 %cond10, i32* @z3, align 4 80 store i32 %cond, i32* @z4, align 4 81 ret void 82 } 83 84 define void @calc_selge() nounwind { 85 entry: 86 %0 = load i32, i32* @a, align 4 87 %1 = load i32, i32* @b, align 4 88 %cmp = icmp sge i32 %0, %1 89 %2 = load i32, i32* @f, align 4 90 %3 = load i32, i32* @t, align 4 91 %cond = select i1 %cmp, i32 %2, i32 %3 92 store i32 %cond, i32* @z1, align 4 93 ; 16: slt ${{[0-9]+}}, ${{[0-9]+}} 94 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}} 95 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 96 %cmp1 = icmp sge i32 %1, %0 97 %cond5 = select i1 %cmp1, i32 %3, i32 %2 98 store i32 %cond5, i32* @z2, align 4 99 %4 = load i32, i32* @c, align 4 100 %cmp6 = icmp sge i32 %4, %0 101 %cond10 = select i1 %cmp6, i32 %3, i32 %2 102 store i32 %cond10, i32* @z3, align 4 103 %cmp11 = icmp sge i32 %0, %4 104 %cond15 = select i1 %cmp11, i32 %3, i32 %2 105 store i32 %cond15, i32* @z4, align 4 106 ret void 107 } 108 109 define i32 @calc_selgt() nounwind { 110 entry: 111 %0 = load i32, i32* @a, align 4 112 %1 = load i32, i32* @b, align 4 113 %cmp = icmp sgt i32 %0, %1 114 ; 16: slt ${{[0-9]+}}, ${{[0-9]+}} 115 ; 16: btnez $BB{{[0-9]+}}_{{[0-9]}} 116 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 117 %2 = load i32, i32* @f, align 4 118 %3 = load i32, i32* @t, align 4 119 %cond = select i1 %cmp, i32 %2, i32 %3 120 store i32 %cond, i32* @z1, align 4 121 %cmp1 = icmp sgt i32 %1, %0 122 %cond5 = select i1 %cmp1, i32 %3, i32 %2 123 store i32 %cond5, i32* @z2, align 4 124 %4 = load i32, i32* @c, align 4 125 %cmp6 = icmp sgt i32 %4, %0 126 %cond10 = select i1 %cmp6, i32 %2, i32 %3 127 store i32 %cond10, i32* @z3, align 4 128 %cmp11 = icmp sgt i32 %0, %4 129 %cond15 = select i1 %cmp11, i32 %2, i32 %3 130 store i32 %cond15, i32* @z4, align 4 131 ret i32 undef 132 } 133 134 define void @calc_selle() nounwind { 135 entry: 136 %0 = load i32, i32* @a, align 4 137 %1 = load i32, i32* @b, align 4 138 %cmp = icmp sle i32 %0, %1 139 %2 = load i32, i32* @t, align 4 140 %3 = load i32, i32* @f, align 4 141 %cond = select i1 %cmp, i32 %2, i32 %3 142 store i32 %cond, i32* @z1, align 4 143 ; 16: slt ${{[0-9]+}}, ${{[0-9]+}} 144 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}} 145 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 146 %cmp1 = icmp sle i32 %1, %0 147 %cond5 = select i1 %cmp1, i32 %3, i32 %2 148 store i32 %cond5, i32* @z2, align 4 149 %4 = load i32, i32* @c, align 4 150 %cmp6 = icmp sle i32 %4, %0 151 %cond10 = select i1 %cmp6, i32 %2, i32 %3 152 store i32 %cond10, i32* @z3, align 4 153 %cmp11 = icmp sle i32 %0, %4 154 %cond15 = select i1 %cmp11, i32 %2, i32 %3 155 store i32 %cond15, i32* @z4, align 4 156 ret void 157 } 158 159 define void @calc_selltk() nounwind { 160 entry: 161 %0 = load i32, i32* @a, align 4 162 %cmp = icmp slt i32 %0, 10 163 %1 = load i32, i32* @t, align 4 164 %2 = load i32, i32* @f, align 4 165 %cond = select i1 %cmp, i32 %1, i32 %2 166 store i32 %cond, i32* @z1, align 4 167 ; 16: slti ${{[0-9]+}}, {{[0-9]+}} 168 ; 16: btnez $BB{{[0-9]+}}_{{[0-9]}} 169 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 170 %3 = load i32, i32* @b, align 4 171 %cmp1 = icmp slt i32 %3, 2 172 %cond5 = select i1 %cmp1, i32 %2, i32 %1 173 store i32 %cond5, i32* @z2, align 4 174 %4 = load i32, i32* @c, align 4 175 %cmp6 = icmp sgt i32 %4, 2 176 %cond10 = select i1 %cmp6, i32 %2, i32 %1 177 store i32 %cond10, i32* @z3, align 4 178 %cmp11 = icmp sgt i32 %0, 2 179 %cond15 = select i1 %cmp11, i32 %2, i32 %1 180 store i32 %cond15, i32* @z4, align 4 181 ret void 182 } 183 184 185 define void @calc_selne() nounwind { 186 entry: 187 %0 = load i32, i32* @a, align 4 188 %1 = load i32, i32* @b, align 4 189 %cmp = icmp ne i32 %0, %1 190 %2 = load i32, i32* @t, align 4 191 %3 = load i32, i32* @f, align 4 192 %cond = select i1 %cmp, i32 %2, i32 %3 193 store i32 %cond, i32* @z1, align 4 194 ; 16: cmp ${{[0-9]+}}, ${{[0-9]+}} 195 ; 16: btnez $BB{{[0-9]+}}_{{[0-9]}} 196 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 197 store i32 %cond, i32* @z2, align 4 198 %4 = load i32, i32* @c, align 4 199 %cmp6 = icmp ne i32 %4, %0 200 %cond10 = select i1 %cmp6, i32 %3, i32 %2 201 store i32 %cond10, i32* @z3, align 4 202 store i32 %cond10, i32* @z4, align 4 203 ret void 204 } 205 206 define void @calc_selnek() nounwind { 207 entry: 208 %0 = load i32, i32* @a, align 4 209 %cmp = icmp ne i32 %0, 1 210 %1 = load i32, i32* @f, align 4 211 %2 = load i32, i32* @t, align 4 212 %cond = select i1 %cmp, i32 %1, i32 %2 213 store i32 %cond, i32* @z1, align 4 214 ; 16: cmpi ${{[0-9]+}}, 1 215 ; 16: btnez $BB{{[0-9]+}}_{{[0-9]}} 216 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 217 %cmp1 = icmp ne i32 %0, 10 218 %cond5 = select i1 %cmp1, i32 %2, i32 %1 219 store i32 %cond5, i32* @z2, align 4 220 %3 = load i32, i32* @b, align 4 221 %cmp6 = icmp ne i32 %3, 3 222 %cond10 = select i1 %cmp6, i32 %2, i32 %1 223 store i32 %cond10, i32* @z3, align 4 224 ; 16: cmpi ${{[0-9]+}}, 10 225 ; 16: btnez $BB{{[0-9]+}}_{{[0-9]}} 226 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 227 %cmp11 = icmp ne i32 %3, 10 228 %cond15 = select i1 %cmp11, i32 %1, i32 %2 229 store i32 %cond15, i32* @z4, align 4 230 ret void 231 } 232 233 define void @calc_selnez() nounwind { 234 entry: 235 %0 = load i32, i32* @a, align 4 236 %cmp = icmp ne i32 %0, 0 237 %1 = load i32, i32* @f, align 4 238 %2 = load i32, i32* @t, align 4 239 %cond = select i1 %cmp, i32 %1, i32 %2 240 store i32 %cond, i32* @z1, align 4 241 ; 16: bnez ${{[0-9]+}}, $BB{{[0-9]+}}_{{[0-9]}} 242 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 243 %3 = load i32, i32* @b, align 4 244 %cmp1 = icmp ne i32 %3, 0 245 %cond5 = select i1 %cmp1, i32 %2, i32 %1 246 store i32 %cond5, i32* @z2, align 4 247 %4 = load i32, i32* @c, align 4 248 %cmp6 = icmp ne i32 %4, 0 249 %cond10 = select i1 %cmp6, i32 %1, i32 %2 250 store i32 %cond10, i32* @z3, align 4 251 store i32 %cond, i32* @z4, align 4 252 ret void 253 } 254 255 define void @calc_selnez2() nounwind { 256 entry: 257 %0 = load i32, i32* @a, align 4 258 %tobool = icmp ne i32 %0, 0 259 %1 = load i32, i32* @f, align 4 260 %2 = load i32, i32* @t, align 4 261 %cond = select i1 %tobool, i32 %1, i32 %2 262 store i32 %cond, i32* @z1, align 4 263 ; 16: bnez ${{[0-9]+}}, $BB{{[0-9]+}}_{{[0-9]}} 264 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 265 %3 = load i32, i32* @b, align 4 266 %tobool1 = icmp ne i32 %3, 0 267 %cond5 = select i1 %tobool1, i32 %2, i32 %1 268 store i32 %cond5, i32* @z2, align 4 269 %4 = load i32, i32* @c, align 4 270 %tobool6 = icmp ne i32 %4, 0 271 %cond10 = select i1 %tobool6, i32 %1, i32 %2 272 store i32 %cond10, i32* @z3, align 4 273 store i32 %cond, i32* @z4, align 4 274 ret void 275 } 276 277 define void @calc_seluge() nounwind { 278 entry: 279 %0 = load i32, i32* @a, align 4 280 %1 = load i32, i32* @b, align 4 281 %cmp = icmp uge i32 %0, %1 282 %2 = load i32, i32* @f, align 4 283 %3 = load i32, i32* @t, align 4 284 %cond = select i1 %cmp, i32 %2, i32 %3 285 store i32 %cond, i32* @z1, align 4 286 ; 16: sltu ${{[0-9]+}}, ${{[0-9]+}} 287 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}} 288 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 289 %cmp1 = icmp uge i32 %1, %0 290 %cond5 = select i1 %cmp1, i32 %3, i32 %2 291 store i32 %cond5, i32* @z2, align 4 292 %4 = load i32, i32* @c, align 4 293 %cmp6 = icmp uge i32 %4, %0 294 %cond10 = select i1 %cmp6, i32 %3, i32 %2 295 store i32 %cond10, i32* @z3, align 4 296 %cmp11 = icmp uge i32 %0, %4 297 %cond15 = select i1 %cmp11, i32 %3, i32 %2 298 store i32 %cond15, i32* @z4, align 4 299 ret void 300 } 301 302 define void @calc_selugt() nounwind { 303 entry: 304 %0 = load i32, i32* @a, align 4 305 %1 = load i32, i32* @b, align 4 306 %cmp = icmp ugt i32 %0, %1 307 %2 = load i32, i32* @f, align 4 308 %3 = load i32, i32* @t, align 4 309 %cond = select i1 %cmp, i32 %2, i32 %3 310 store i32 %cond, i32* @z1, align 4 311 ; 16: sltu ${{[0-9]+}}, ${{[0-9]+}} 312 ; 16: btnez $BB{{[0-9]+}}_{{[0-9]}} 313 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 314 %cmp1 = icmp ugt i32 %1, %0 315 %cond5 = select i1 %cmp1, i32 %3, i32 %2 316 store i32 %cond5, i32* @z2, align 4 317 %4 = load i32, i32* @c, align 4 318 %cmp6 = icmp ugt i32 %4, %0 319 %cond10 = select i1 %cmp6, i32 %2, i32 %3 320 store i32 %cond10, i32* @z3, align 4 321 %cmp11 = icmp ugt i32 %0, %4 322 %cond15 = select i1 %cmp11, i32 %2, i32 %3 323 store i32 %cond15, i32* @z4, align 4 324 ret void 325 } 326 327 define void @calc_selule() nounwind { 328 entry: 329 %0 = load i32, i32* @a, align 4 330 %1 = load i32, i32* @b, align 4 331 %cmp = icmp ule i32 %0, %1 332 %2 = load i32, i32* @t, align 4 333 %3 = load i32, i32* @f, align 4 334 %cond = select i1 %cmp, i32 %2, i32 %3 335 store i32 %cond, i32* @z1, align 4 336 ; 16: sltu ${{[0-9]+}}, ${{[0-9]+}} 337 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}} 338 ; 16: move ${{[0-9]+}}, ${{[0-9]+}} 339 %cmp1 = icmp ule i32 %1, %0 340 %cond5 = select i1 %cmp1, i32 %3, i32 %2 341 store i32 %cond5, i32* @z2, align 4 342 %4 = load i32, i32* @c, align 4 343 %cmp6 = icmp ule i32 %4, %0 344 %cond10 = select i1 %cmp6, i32 %2, i32 %3 345 store i32 %cond10, i32* @z3, align 4 346 %cmp11 = icmp ule i32 %0, %4 347 %cond15 = select i1 %cmp11, i32 %2, i32 %3 348 store i32 %cond15, i32* @z4, align 4 349 ret void 350 } 351