1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s 3 4 define void @test64(i64 inreg %x) { 5 ; CHECK-LABEL: test64: 6 ; CHECK: # %bb.0: 7 ; CHECK-NEXT: pushq %rax 8 ; CHECK-NEXT: .cfi_def_cfa_offset 16 9 ; CHECK-NEXT: testl $2048, %edi # imm = 0x800 10 ; CHECK-NEXT: jne .LBB0_2 11 ; CHECK-NEXT: # %bb.1: # %yes 12 ; CHECK-NEXT: callq bar 13 ; CHECK-NEXT: .LBB0_2: # %no 14 ; CHECK-NEXT: popq %rax 15 ; CHECK-NEXT: .cfi_def_cfa_offset 8 16 ; CHECK-NEXT: retq 17 %t = and i64 %x, 2048 18 %s = icmp eq i64 %t, 0 19 br i1 %s, label %yes, label %no 20 21 yes: 22 call void @bar() 23 ret void 24 no: 25 ret void 26 } 27 28 define void @test64_optsize(i64 inreg %x) optsize { 29 ; CHECK-LABEL: test64_optsize: 30 ; CHECK: # %bb.0: 31 ; CHECK-NEXT: pushq %rax 32 ; CHECK-NEXT: .cfi_def_cfa_offset 16 33 ; CHECK-NEXT: btl $11, %edi 34 ; CHECK-NEXT: jb .LBB1_2 35 ; CHECK-NEXT: # %bb.1: # %yes 36 ; CHECK-NEXT: callq bar 37 ; CHECK-NEXT: .LBB1_2: # %no 38 ; CHECK-NEXT: popq %rax 39 ; CHECK-NEXT: .cfi_def_cfa_offset 8 40 ; CHECK-NEXT: retq 41 %t = and i64 %x, 2048 42 %s = icmp eq i64 %t, 0 43 br i1 %s, label %yes, label %no 44 45 yes: 46 call void @bar() 47 ret void 48 no: 49 ret void 50 } 51 52 ; This test is identical to test64 above with only the destination of the br 53 ; reversed. This somehow causes the two functions to get slightly different 54 ; initial IR. One has an extra invert of the setcc. This previous caused one 55 ; the functions to use a BT while the other used a TEST due to another DAG 56 ; combine messing with an expected canonical form. 57 define void @test64_2(i64 inreg %x) { 58 ; CHECK-LABEL: test64_2: 59 ; CHECK: # %bb.0: 60 ; CHECK-NEXT: pushq %rax 61 ; CHECK-NEXT: .cfi_def_cfa_offset 16 62 ; CHECK-NEXT: testl $2048, %edi # imm = 0x800 63 ; CHECK-NEXT: je .LBB2_2 64 ; CHECK-NEXT: # %bb.1: # %yes 65 ; CHECK-NEXT: callq bar 66 ; CHECK-NEXT: .LBB2_2: # %no 67 ; CHECK-NEXT: popq %rax 68 ; CHECK-NEXT: .cfi_def_cfa_offset 8 69 ; CHECK-NEXT: retq 70 %t = and i64 %x, 2048 71 %s = icmp eq i64 %t, 0 72 br i1 %s, label %no, label %yes 73 74 yes: 75 call void @bar() 76 ret void 77 no: 78 ret void 79 } 80 81 define void @test64_optsize_2(i64 inreg %x) optsize { 82 ; CHECK-LABEL: test64_optsize_2: 83 ; CHECK: # %bb.0: 84 ; CHECK-NEXT: pushq %rax 85 ; CHECK-NEXT: .cfi_def_cfa_offset 16 86 ; CHECK-NEXT: btl $11, %edi 87 ; CHECK-NEXT: jae .LBB3_2 88 ; CHECK-NEXT: # %bb.1: # %yes 89 ; CHECK-NEXT: callq bar 90 ; CHECK-NEXT: .LBB3_2: # %no 91 ; CHECK-NEXT: popq %rax 92 ; CHECK-NEXT: .cfi_def_cfa_offset 8 93 ; CHECK-NEXT: retq 94 %t = and i64 %x, 2048 95 %s = icmp eq i64 %t, 0 96 br i1 %s, label %no, label %yes 97 98 yes: 99 call void @bar() 100 ret void 101 no: 102 ret void 103 } 104 105 define void @test64_3(i64 inreg %x) { 106 ; CHECK-LABEL: test64_3: 107 ; CHECK: # %bb.0: 108 ; CHECK-NEXT: pushq %rax 109 ; CHECK-NEXT: .cfi_def_cfa_offset 16 110 ; CHECK-NEXT: btq $32, %rdi 111 ; CHECK-NEXT: jb .LBB4_2 112 ; CHECK-NEXT: # %bb.1: # %yes 113 ; CHECK-NEXT: callq bar 114 ; CHECK-NEXT: .LBB4_2: # %no 115 ; CHECK-NEXT: popq %rax 116 ; CHECK-NEXT: .cfi_def_cfa_offset 8 117 ; CHECK-NEXT: retq 118 %t = and i64 %x, 4294967296 119 %s = icmp eq i64 %t, 0 120 br i1 %s, label %yes, label %no 121 122 yes: 123 call void @bar() 124 ret void 125 no: 126 ret void 127 } 128 129 define void @test64_optsize_3(i64 inreg %x) optsize { 130 ; CHECK-LABEL: test64_optsize_3: 131 ; CHECK: # %bb.0: 132 ; CHECK-NEXT: pushq %rax 133 ; CHECK-NEXT: .cfi_def_cfa_offset 16 134 ; CHECK-NEXT: btq $32, %rdi 135 ; CHECK-NEXT: jb .LBB5_2 136 ; CHECK-NEXT: # %bb.1: # %yes 137 ; CHECK-NEXT: callq bar 138 ; CHECK-NEXT: .LBB5_2: # %no 139 ; CHECK-NEXT: popq %rax 140 ; CHECK-NEXT: .cfi_def_cfa_offset 8 141 ; CHECK-NEXT: retq 142 %t = and i64 %x, 4294967296 143 %s = icmp eq i64 %t, 0 144 br i1 %s, label %yes, label %no 145 146 yes: 147 call void @bar() 148 ret void 149 no: 150 ret void 151 } 152 153 define void @test64_4(i64 inreg %x) { 154 ; CHECK-LABEL: test64_4: 155 ; CHECK: # %bb.0: 156 ; CHECK-NEXT: pushq %rax 157 ; CHECK-NEXT: .cfi_def_cfa_offset 16 158 ; CHECK-NEXT: btq $32, %rdi 159 ; CHECK-NEXT: jae .LBB6_2 160 ; CHECK-NEXT: # %bb.1: # %yes 161 ; CHECK-NEXT: callq bar 162 ; CHECK-NEXT: .LBB6_2: # %no 163 ; CHECK-NEXT: popq %rax 164 ; CHECK-NEXT: .cfi_def_cfa_offset 8 165 ; CHECK-NEXT: retq 166 %t = and i64 %x, 4294967296 167 %s = icmp eq i64 %t, 0 168 br i1 %s, label %no, label %yes 169 170 yes: 171 call void @bar() 172 ret void 173 no: 174 ret void 175 } 176 177 define void @test64_optsize_4(i64 inreg %x) optsize { 178 ; CHECK-LABEL: test64_optsize_4: 179 ; CHECK: # %bb.0: 180 ; CHECK-NEXT: pushq %rax 181 ; CHECK-NEXT: .cfi_def_cfa_offset 16 182 ; CHECK-NEXT: btq $32, %rdi 183 ; CHECK-NEXT: jae .LBB7_2 184 ; CHECK-NEXT: # %bb.1: # %yes 185 ; CHECK-NEXT: callq bar 186 ; CHECK-NEXT: .LBB7_2: # %no 187 ; CHECK-NEXT: popq %rax 188 ; CHECK-NEXT: .cfi_def_cfa_offset 8 189 ; CHECK-NEXT: retq 190 %t = and i64 %x, 4294967296 191 %s = icmp eq i64 %t, 0 192 br i1 %s, label %no, label %yes 193 194 yes: 195 call void @bar() 196 ret void 197 no: 198 ret void 199 } 200 201 define void @test32(i32 inreg %x) { 202 ; CHECK-LABEL: test32: 203 ; CHECK: # %bb.0: 204 ; CHECK-NEXT: pushq %rax 205 ; CHECK-NEXT: .cfi_def_cfa_offset 16 206 ; CHECK-NEXT: testl $2048, %edi # imm = 0x800 207 ; CHECK-NEXT: jne .LBB8_2 208 ; CHECK-NEXT: # %bb.1: # %yes 209 ; CHECK-NEXT: callq bar 210 ; CHECK-NEXT: .LBB8_2: # %no 211 ; CHECK-NEXT: popq %rax 212 ; CHECK-NEXT: .cfi_def_cfa_offset 8 213 ; CHECK-NEXT: retq 214 %t = and i32 %x, 2048 215 %s = icmp eq i32 %t, 0 216 br i1 %s, label %yes, label %no 217 218 yes: 219 call void @bar() 220 ret void 221 no: 222 ret void 223 } 224 225 define void @test32_optsize(i32 inreg %x) optsize { 226 ; CHECK-LABEL: test32_optsize: 227 ; CHECK: # %bb.0: 228 ; CHECK-NEXT: pushq %rax 229 ; CHECK-NEXT: .cfi_def_cfa_offset 16 230 ; CHECK-NEXT: btl $11, %edi 231 ; CHECK-NEXT: jb .LBB9_2 232 ; CHECK-NEXT: # %bb.1: # %yes 233 ; CHECK-NEXT: callq bar 234 ; CHECK-NEXT: .LBB9_2: # %no 235 ; CHECK-NEXT: popq %rax 236 ; CHECK-NEXT: .cfi_def_cfa_offset 8 237 ; CHECK-NEXT: retq 238 %t = and i32 %x, 2048 239 %s = icmp eq i32 %t, 0 240 br i1 %s, label %yes, label %no 241 242 yes: 243 call void @bar() 244 ret void 245 no: 246 ret void 247 } 248 249 define void @test32_2(i32 inreg %x) { 250 ; CHECK-LABEL: test32_2: 251 ; CHECK: # %bb.0: 252 ; CHECK-NEXT: pushq %rax 253 ; CHECK-NEXT: .cfi_def_cfa_offset 16 254 ; CHECK-NEXT: testl $2048, %edi # imm = 0x800 255 ; CHECK-NEXT: je .LBB10_2 256 ; CHECK-NEXT: # %bb.1: # %yes 257 ; CHECK-NEXT: callq bar 258 ; CHECK-NEXT: .LBB10_2: # %no 259 ; CHECK-NEXT: popq %rax 260 ; CHECK-NEXT: .cfi_def_cfa_offset 8 261 ; CHECK-NEXT: retq 262 %t = and i32 %x, 2048 263 %s = icmp eq i32 %t, 0 264 br i1 %s, label %no, label %yes 265 266 yes: 267 call void @bar() 268 ret void 269 no: 270 ret void 271 } 272 273 define void @test32_optsize_2(i32 inreg %x) optsize { 274 ; CHECK-LABEL: test32_optsize_2: 275 ; CHECK: # %bb.0: 276 ; CHECK-NEXT: pushq %rax 277 ; CHECK-NEXT: .cfi_def_cfa_offset 16 278 ; CHECK-NEXT: btl $11, %edi 279 ; CHECK-NEXT: jae .LBB11_2 280 ; CHECK-NEXT: # %bb.1: # %yes 281 ; CHECK-NEXT: callq bar 282 ; CHECK-NEXT: .LBB11_2: # %no 283 ; CHECK-NEXT: popq %rax 284 ; CHECK-NEXT: .cfi_def_cfa_offset 8 285 ; CHECK-NEXT: retq 286 %t = and i32 %x, 2048 287 %s = icmp eq i32 %t, 0 288 br i1 %s, label %no, label %yes 289 290 yes: 291 call void @bar() 292 ret void 293 no: 294 ret void 295 } 296 297 define void @test16(i16 inreg %x) { 298 ; CHECK-LABEL: test16: 299 ; CHECK: # %bb.0: 300 ; CHECK-NEXT: pushq %rax 301 ; CHECK-NEXT: .cfi_def_cfa_offset 16 302 ; CHECK-NEXT: testl $2048, %edi # imm = 0x800 303 ; CHECK-NEXT: jne .LBB12_2 304 ; CHECK-NEXT: # %bb.1: # %yes 305 ; CHECK-NEXT: callq bar 306 ; CHECK-NEXT: .LBB12_2: # %no 307 ; CHECK-NEXT: popq %rax 308 ; CHECK-NEXT: .cfi_def_cfa_offset 8 309 ; CHECK-NEXT: retq 310 %t = and i16 %x, 2048 311 %s = icmp eq i16 %t, 0 312 br i1 %s, label %yes, label %no 313 314 yes: 315 call void @bar() 316 ret void 317 no: 318 ret void 319 } 320 321 define void @test16_optsize(i16 inreg %x) optsize { 322 ; CHECK-LABEL: test16_optsize: 323 ; CHECK: # %bb.0: 324 ; CHECK-NEXT: pushq %rax 325 ; CHECK-NEXT: .cfi_def_cfa_offset 16 326 ; CHECK-NEXT: btl $11, %edi 327 ; CHECK-NEXT: jb .LBB13_2 328 ; CHECK-NEXT: # %bb.1: # %yes 329 ; CHECK-NEXT: callq bar 330 ; CHECK-NEXT: .LBB13_2: # %no 331 ; CHECK-NEXT: popq %rax 332 ; CHECK-NEXT: .cfi_def_cfa_offset 8 333 ; CHECK-NEXT: retq 334 %t = and i16 %x, 2048 335 %s = icmp eq i16 %t, 0 336 br i1 %s, label %yes, label %no 337 338 yes: 339 call void @bar() 340 ret void 341 no: 342 ret void 343 } 344 345 define void @test16_2(i16 inreg %x) { 346 ; CHECK-LABEL: test16_2: 347 ; CHECK: # %bb.0: 348 ; CHECK-NEXT: pushq %rax 349 ; CHECK-NEXT: .cfi_def_cfa_offset 16 350 ; CHECK-NEXT: testl $2048, %edi # imm = 0x800 351 ; CHECK-NEXT: je .LBB14_2 352 ; CHECK-NEXT: # %bb.1: # %yes 353 ; CHECK-NEXT: callq bar 354 ; CHECK-NEXT: .LBB14_2: # %no 355 ; CHECK-NEXT: popq %rax 356 ; CHECK-NEXT: .cfi_def_cfa_offset 8 357 ; CHECK-NEXT: retq 358 %t = and i16 %x, 2048 359 %s = icmp eq i16 %t, 0 360 br i1 %s, label %no, label %yes 361 362 yes: 363 call void @bar() 364 ret void 365 no: 366 ret void 367 } 368 369 define void @test16_optsize_2(i16 inreg %x) optsize { 370 ; CHECK-LABEL: test16_optsize_2: 371 ; CHECK: # %bb.0: 372 ; CHECK-NEXT: pushq %rax 373 ; CHECK-NEXT: .cfi_def_cfa_offset 16 374 ; CHECK-NEXT: btl $11, %edi 375 ; CHECK-NEXT: jae .LBB15_2 376 ; CHECK-NEXT: # %bb.1: # %yes 377 ; CHECK-NEXT: callq bar 378 ; CHECK-NEXT: .LBB15_2: # %no 379 ; CHECK-NEXT: popq %rax 380 ; CHECK-NEXT: .cfi_def_cfa_offset 8 381 ; CHECK-NEXT: retq 382 %t = and i16 %x, 2048 383 %s = icmp eq i16 %t, 0 384 br i1 %s, label %no, label %yes 385 386 yes: 387 call void @bar() 388 ret void 389 no: 390 ret void 391 } 392 393 declare void @bar() 394