1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4; This is https://bugs.llvm.org/show_bug.cgi?id=36682 5 6; In *all* of these, sitofp and bitcast should be instcombine'd out. 7; "sle 0" is canonicalized to "slt 1", so we don't test "sle 0" case. 8; "sge 0" is canonicalized to "sgt -1", so we don't test "sge 0" case. 9; "sge 1" is canonicalized to "sgt 0", so we don't test "sge 1" case. 10; "sle -1" is canonicalized to "slt 0", so we don't test "sle -1" case. 11 12define i1 @i32_cast_cmp_eq_int_0_sitofp_float(i32 %i) { 13; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_float( 14; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0 15; CHECK-NEXT: ret i1 [[CMP]] 16; 17 %f = sitofp i32 %i to float 18 %b = bitcast float %f to i32 19 %cmp = icmp eq i32 %b, 0 20 ret i1 %cmp 21} 22 23define i1 @i32_cast_cmp_ne_int_0_sitofp_float(i32 %i) { 24; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_float( 25; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0 26; CHECK-NEXT: ret i1 [[CMP]] 27; 28 %f = sitofp i32 %i to float 29 %b = bitcast float %f to i32 30 %cmp = icmp ne i32 %b, 0 31 ret i1 %cmp 32} 33 34define i1 @i32_cast_cmp_slt_int_0_sitofp_float(i32 %i) { 35; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_float( 36; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 0 37; CHECK-NEXT: ret i1 [[CMP]] 38; 39 %f = sitofp i32 %i to float 40 %b = bitcast float %f to i32 41 %cmp = icmp slt i32 %b, 0 42 ret i1 %cmp 43} 44 45define i1 @i32_cast_cmp_sgt_int_0_sitofp_float(i32 %i) { 46; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_float( 47; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 0 48; CHECK-NEXT: ret i1 [[CMP]] 49; 50 %f = sitofp i32 %i to float 51 %b = bitcast float %f to i32 52 %cmp = icmp sgt i32 %b, 0 53 ret i1 %cmp 54} 55 56define i1 @i32_cast_cmp_slt_int_1_sitofp_float(i32 %i) { 57; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_float( 58; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 1 59; CHECK-NEXT: ret i1 [[CMP]] 60; 61 %f = sitofp i32 %i to float 62 %b = bitcast float %f to i32 63 %cmp = icmp slt i32 %b, 1 64 ret i1 %cmp 65} 66 67define i1 @i32_cast_cmp_sgt_int_m1_sitofp_float(i32 %i) { 68; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_float( 69; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -1 70; CHECK-NEXT: ret i1 [[CMP]] 71; 72 %f = sitofp i32 %i to float 73 %b = bitcast float %f to i32 74 %cmp = icmp sgt i32 %b, -1 75 ret i1 %cmp 76} 77 78define i1 @i32_cast_cmp_eq_int_0_sitofp_double(i32 %i) { 79; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_double( 80; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0 81; CHECK-NEXT: ret i1 [[CMP]] 82; 83 %f = sitofp i32 %i to double 84 %b = bitcast double %f to i64 85 %cmp = icmp eq i64 %b, 0 86 ret i1 %cmp 87} 88 89define i1 @i32_cast_cmp_ne_int_0_sitofp_double(i32 %i) { 90; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_double( 91; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0 92; CHECK-NEXT: ret i1 [[CMP]] 93; 94 %f = sitofp i32 %i to double 95 %b = bitcast double %f to i64 96 %cmp = icmp ne i64 %b, 0 97 ret i1 %cmp 98} 99 100define i1 @i32_cast_cmp_slt_int_0_sitofp_double(i32 %i) { 101; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_double( 102; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 0 103; CHECK-NEXT: ret i1 [[CMP]] 104; 105 %f = sitofp i32 %i to double 106 %b = bitcast double %f to i64 107 %cmp = icmp slt i64 %b, 0 108 ret i1 %cmp 109} 110 111define i1 @i32_cast_cmp_sgt_int_0_sitofp_double(i32 %i) { 112; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_double( 113; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 0 114; CHECK-NEXT: ret i1 [[CMP]] 115; 116 %f = sitofp i32 %i to double 117 %b = bitcast double %f to i64 118 %cmp = icmp sgt i64 %b, 0 119 ret i1 %cmp 120} 121 122define i1 @i32_cast_cmp_slt_int_1_sitofp_double(i32 %i) { 123; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_double( 124; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 1 125; CHECK-NEXT: ret i1 [[CMP]] 126; 127 %f = sitofp i32 %i to double 128 %b = bitcast double %f to i64 129 %cmp = icmp slt i64 %b, 1 130 ret i1 %cmp 131} 132 133define i1 @i32_cast_cmp_sgt_int_m1_sitofp_double(i32 %i) { 134; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_double( 135; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -1 136; CHECK-NEXT: ret i1 [[CMP]] 137; 138 %f = sitofp i32 %i to double 139 %b = bitcast double %f to i64 140 %cmp = icmp sgt i64 %b, -1 141 ret i1 %cmp 142} 143 144define i1 @i32_cast_cmp_eq_int_0_sitofp_half(i32 %i) { 145; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_half( 146; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0 147; CHECK-NEXT: ret i1 [[CMP]] 148; 149 %f = sitofp i32 %i to half 150 %b = bitcast half %f to i16 151 %cmp = icmp eq i16 %b, 0 152 ret i1 %cmp 153} 154 155define i1 @i32_cast_cmp_ne_int_0_sitofp_half(i32 %i) { 156; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_half( 157; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0 158; CHECK-NEXT: ret i1 [[CMP]] 159; 160 %f = sitofp i32 %i to half 161 %b = bitcast half %f to i16 162 %cmp = icmp ne i16 %b, 0 163 ret i1 %cmp 164} 165 166define i1 @i32_cast_cmp_slt_int_0_sitofp_half(i32 %i) { 167; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_half( 168; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 0 169; CHECK-NEXT: ret i1 [[CMP]] 170; 171 %f = sitofp i32 %i to half 172 %b = bitcast half %f to i16 173 %cmp = icmp slt i16 %b, 0 174 ret i1 %cmp 175} 176 177define i1 @i32_cast_cmp_sgt_int_0_sitofp_half(i32 %i) { 178; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_half( 179; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 0 180; CHECK-NEXT: ret i1 [[CMP]] 181; 182 %f = sitofp i32 %i to half 183 %b = bitcast half %f to i16 184 %cmp = icmp sgt i16 %b, 0 185 ret i1 %cmp 186} 187 188define i1 @i32_cast_cmp_slt_int_1_sitofp_half(i32 %i) { 189; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_half( 190; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 1 191; CHECK-NEXT: ret i1 [[CMP]] 192; 193 %f = sitofp i32 %i to half 194 %b = bitcast half %f to i16 195 %cmp = icmp slt i16 %b, 1 196 ret i1 %cmp 197} 198 199define i1 @i32_cast_cmp_sgt_int_m1_sitofp_half(i32 %i) { 200; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_half( 201; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -1 202; CHECK-NEXT: ret i1 [[CMP]] 203; 204 %f = sitofp i32 %i to half 205 %b = bitcast half %f to i16 206 %cmp = icmp sgt i16 %b, -1 207 ret i1 %cmp 208} 209 210define i1 @i64_cast_cmp_eq_int_0_sitofp_float(i64 %i) { 211; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_float( 212; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0 213; CHECK-NEXT: ret i1 [[CMP]] 214; 215 %f = sitofp i64 %i to float 216 %b = bitcast float %f to i32 217 %cmp = icmp eq i32 %b, 0 218 ret i1 %cmp 219} 220 221define i1 @i64_cast_cmp_ne_int_0_sitofp_float(i64 %i) { 222; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_float( 223; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0 224; CHECK-NEXT: ret i1 [[CMP]] 225; 226 %f = sitofp i64 %i to float 227 %b = bitcast float %f to i32 228 %cmp = icmp ne i32 %b, 0 229 ret i1 %cmp 230} 231 232define i1 @i64_cast_cmp_slt_int_0_sitofp_float(i64 %i) { 233; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_float( 234; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0 235; CHECK-NEXT: ret i1 [[CMP]] 236; 237 %f = sitofp i64 %i to float 238 %b = bitcast float %f to i32 239 %cmp = icmp slt i32 %b, 0 240 ret i1 %cmp 241} 242 243define i1 @i64_cast_cmp_sgt_int_0_sitofp_float(i64 %i) { 244; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_float( 245; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0 246; CHECK-NEXT: ret i1 [[CMP]] 247; 248 %f = sitofp i64 %i to float 249 %b = bitcast float %f to i32 250 %cmp = icmp sgt i32 %b, 0 251 ret i1 %cmp 252} 253 254define i1 @i64_cast_cmp_slt_int_1_sitofp_float(i64 %i) { 255; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_float( 256; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1 257; CHECK-NEXT: ret i1 [[CMP]] 258; 259 %f = sitofp i64 %i to float 260 %b = bitcast float %f to i32 261 %cmp = icmp slt i32 %b, 1 262 ret i1 %cmp 263} 264 265define i1 @i64_cast_cmp_sgt_int_m1_sitofp_float(i64 %i) { 266; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_float( 267; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1 268; CHECK-NEXT: ret i1 [[CMP]] 269; 270 %f = sitofp i64 %i to float 271 %b = bitcast float %f to i32 272 %cmp = icmp sgt i32 %b, -1 273 ret i1 %cmp 274} 275 276define i1 @i64_cast_cmp_eq_int_0_sitofp_double(i64 %i) { 277; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_double( 278; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0 279; CHECK-NEXT: ret i1 [[CMP]] 280; 281 %f = sitofp i64 %i to double 282 %b = bitcast double %f to i64 283 %cmp = icmp eq i64 %b, 0 284 ret i1 %cmp 285} 286 287define i1 @i64_cast_cmp_ne_int_0_sitofp_double(i64 %i) { 288; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_double( 289; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0 290; CHECK-NEXT: ret i1 [[CMP]] 291; 292 %f = sitofp i64 %i to double 293 %b = bitcast double %f to i64 294 %cmp = icmp ne i64 %b, 0 295 ret i1 %cmp 296} 297 298define i1 @i64_cast_cmp_slt_int_0_sitofp_double(i64 %i) { 299; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_double( 300; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0 301; CHECK-NEXT: ret i1 [[CMP]] 302; 303 %f = sitofp i64 %i to double 304 %b = bitcast double %f to i64 305 %cmp = icmp slt i64 %b, 0 306 ret i1 %cmp 307} 308 309define i1 @i64_cast_cmp_sgt_int_0_sitofp_double(i64 %i) { 310; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_double( 311; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0 312; CHECK-NEXT: ret i1 [[CMP]] 313; 314 %f = sitofp i64 %i to double 315 %b = bitcast double %f to i64 316 %cmp = icmp sgt i64 %b, 0 317 ret i1 %cmp 318} 319 320define i1 @i64_cast_cmp_slt_int_1_sitofp_double(i64 %i) { 321; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_double( 322; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1 323; CHECK-NEXT: ret i1 [[CMP]] 324; 325 %f = sitofp i64 %i to double 326 %b = bitcast double %f to i64 327 %cmp = icmp slt i64 %b, 1 328 ret i1 %cmp 329} 330 331define i1 @i64_cast_cmp_sgt_int_m1_sitofp_double(i64 %i) { 332; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_double( 333; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1 334; CHECK-NEXT: ret i1 [[CMP]] 335; 336 %f = sitofp i64 %i to double 337 %b = bitcast double %f to i64 338 %cmp = icmp sgt i64 %b, -1 339 ret i1 %cmp 340} 341 342define i1 @i64_cast_cmp_eq_int_0_sitofp_half(i64 %i) { 343; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_half( 344; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0 345; CHECK-NEXT: ret i1 [[CMP]] 346; 347 %f = sitofp i64 %i to half 348 %b = bitcast half %f to i16 349 %cmp = icmp eq i16 %b, 0 350 ret i1 %cmp 351} 352 353define i1 @i64_cast_cmp_ne_int_0_sitofp_half(i64 %i) { 354; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_half( 355; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0 356; CHECK-NEXT: ret i1 [[CMP]] 357; 358 %f = sitofp i64 %i to half 359 %b = bitcast half %f to i16 360 %cmp = icmp ne i16 %b, 0 361 ret i1 %cmp 362} 363 364define i1 @i64_cast_cmp_slt_int_0_sitofp_half(i64 %i) { 365; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_half( 366; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0 367; CHECK-NEXT: ret i1 [[CMP]] 368; 369 %f = sitofp i64 %i to half 370 %b = bitcast half %f to i16 371 %cmp = icmp slt i16 %b, 0 372 ret i1 %cmp 373} 374 375define i1 @i64_cast_cmp_sgt_int_0_sitofp_half(i64 %i) { 376; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_half( 377; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0 378; CHECK-NEXT: ret i1 [[CMP]] 379; 380 %f = sitofp i64 %i to half 381 %b = bitcast half %f to i16 382 %cmp = icmp sgt i16 %b, 0 383 ret i1 %cmp 384} 385 386define i1 @i64_cast_cmp_slt_int_1_sitofp_half(i64 %i) { 387; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_half( 388; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1 389; CHECK-NEXT: ret i1 [[CMP]] 390; 391 %f = sitofp i64 %i to half 392 %b = bitcast half %f to i16 393 %cmp = icmp slt i16 %b, 1 394 ret i1 %cmp 395} 396 397define i1 @i64_cast_cmp_sgt_int_m1_sitofp_half(i64 %i) { 398; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_half( 399; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1 400; CHECK-NEXT: ret i1 [[CMP]] 401; 402 %f = sitofp i64 %i to half 403 %b = bitcast half %f to i16 404 %cmp = icmp sgt i16 %b, -1 405 ret i1 %cmp 406} 407 408define i1 @i16_cast_cmp_eq_int_0_sitofp_float(i16 %i) { 409; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_float( 410; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0 411; CHECK-NEXT: ret i1 [[CMP]] 412; 413 %f = sitofp i16 %i to float 414 %b = bitcast float %f to i32 415 %cmp = icmp eq i32 %b, 0 416 ret i1 %cmp 417} 418 419define i1 @i16_cast_cmp_ne_int_0_sitofp_float(i16 %i) { 420; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_float( 421; CHECK-NEXT: [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0 422; CHECK-NEXT: ret i1 [[CMP]] 423; 424 %f = sitofp i16 %i to float 425 %b = bitcast float %f to i32 426 %cmp = icmp ne i32 %b, 0 427 ret i1 %cmp 428} 429 430define i1 @i16_cast_cmp_slt_int_0_sitofp_float(i16 %i) { 431; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_float( 432; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0 433; CHECK-NEXT: ret i1 [[CMP]] 434; 435 %f = sitofp i16 %i to float 436 %b = bitcast float %f to i32 437 %cmp = icmp slt i32 %b, 0 438 ret i1 %cmp 439} 440 441define i1 @i16_cast_cmp_sgt_int_0_sitofp_float(i16 %i) { 442; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_float( 443; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0 444; CHECK-NEXT: ret i1 [[CMP]] 445; 446 %f = sitofp i16 %i to float 447 %b = bitcast float %f to i32 448 %cmp = icmp sgt i32 %b, 0 449 ret i1 %cmp 450} 451 452define i1 @i16_cast_cmp_slt_int_1_sitofp_float(i16 %i) { 453; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_float( 454; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1 455; CHECK-NEXT: ret i1 [[CMP]] 456; 457 %f = sitofp i16 %i to float 458 %b = bitcast float %f to i32 459 %cmp = icmp slt i32 %b, 1 460 ret i1 %cmp 461} 462 463define i1 @i16_cast_cmp_sgt_int_m1_sitofp_float(i16 %i) { 464; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_float( 465; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1 466; CHECK-NEXT: ret i1 [[CMP]] 467; 468 %f = sitofp i16 %i to float 469 %b = bitcast float %f to i32 470 %cmp = icmp sgt i32 %b, -1 471 ret i1 %cmp 472} 473 474define i1 @i16_cast_cmp_eq_int_0_sitofp_double(i16 %i) { 475; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_double( 476; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0 477; CHECK-NEXT: ret i1 [[CMP]] 478; 479 %f = sitofp i16 %i to double 480 %b = bitcast double %f to i64 481 %cmp = icmp eq i64 %b, 0 482 ret i1 %cmp 483} 484 485define i1 @i16_cast_cmp_ne_int_0_sitofp_double(i16 %i) { 486; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_double( 487; CHECK-NEXT: [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0 488; CHECK-NEXT: ret i1 [[CMP]] 489; 490 %f = sitofp i16 %i to double 491 %b = bitcast double %f to i64 492 %cmp = icmp ne i64 %b, 0 493 ret i1 %cmp 494} 495 496define i1 @i16_cast_cmp_slt_int_0_sitofp_double(i16 %i) { 497; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_double( 498; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0 499; CHECK-NEXT: ret i1 [[CMP]] 500; 501 %f = sitofp i16 %i to double 502 %b = bitcast double %f to i64 503 %cmp = icmp slt i64 %b, 0 504 ret i1 %cmp 505} 506 507define i1 @i16_cast_cmp_sgt_int_0_sitofp_double(i16 %i) { 508; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_double( 509; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0 510; CHECK-NEXT: ret i1 [[CMP]] 511; 512 %f = sitofp i16 %i to double 513 %b = bitcast double %f to i64 514 %cmp = icmp sgt i64 %b, 0 515 ret i1 %cmp 516} 517 518define i1 @i16_cast_cmp_slt_int_1_sitofp_double(i16 %i) { 519; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_double( 520; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1 521; CHECK-NEXT: ret i1 [[CMP]] 522; 523 %f = sitofp i16 %i to double 524 %b = bitcast double %f to i64 525 %cmp = icmp slt i64 %b, 1 526 ret i1 %cmp 527} 528 529define i1 @i16_cast_cmp_sgt_int_m1_sitofp_double(i16 %i) { 530; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_double( 531; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1 532; CHECK-NEXT: ret i1 [[CMP]] 533; 534 %f = sitofp i16 %i to double 535 %b = bitcast double %f to i64 536 %cmp = icmp sgt i64 %b, -1 537 ret i1 %cmp 538} 539 540define i1 @i16_cast_cmp_eq_int_0_sitofp_half(i16 %i) { 541; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_half( 542; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0 543; CHECK-NEXT: ret i1 [[CMP]] 544; 545 %f = sitofp i16 %i to half 546 %b = bitcast half %f to i16 547 %cmp = icmp eq i16 %b, 0 548 ret i1 %cmp 549} 550 551define i1 @i16_cast_cmp_ne_int_0_sitofp_half(i16 %i) { 552; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_half( 553; CHECK-NEXT: [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0 554; CHECK-NEXT: ret i1 [[CMP]] 555; 556 %f = sitofp i16 %i to half 557 %b = bitcast half %f to i16 558 %cmp = icmp ne i16 %b, 0 559 ret i1 %cmp 560} 561 562define i1 @i16_cast_cmp_slt_int_0_sitofp_half(i16 %i) { 563; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_half( 564; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0 565; CHECK-NEXT: ret i1 [[CMP]] 566; 567 %f = sitofp i16 %i to half 568 %b = bitcast half %f to i16 569 %cmp = icmp slt i16 %b, 0 570 ret i1 %cmp 571} 572 573define i1 @i16_cast_cmp_sgt_int_0_sitofp_half(i16 %i) { 574; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_half( 575; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0 576; CHECK-NEXT: ret i1 [[CMP]] 577; 578 %f = sitofp i16 %i to half 579 %b = bitcast half %f to i16 580 %cmp = icmp sgt i16 %b, 0 581 ret i1 %cmp 582} 583 584define i1 @i16_cast_cmp_slt_int_1_sitofp_half(i16 %i) { 585; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_half( 586; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1 587; CHECK-NEXT: ret i1 [[CMP]] 588; 589 %f = sitofp i16 %i to half 590 %b = bitcast half %f to i16 591 %cmp = icmp slt i16 %b, 1 592 ret i1 %cmp 593} 594 595define i1 @i16_cast_cmp_sgt_int_m1_sitofp_half(i16 %i) { 596; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_half( 597; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1 598; CHECK-NEXT: ret i1 [[CMP]] 599; 600 %f = sitofp i16 %i to half 601 %b = bitcast half %f to i16 602 %cmp = icmp sgt i16 %b, -1 603 ret i1 %cmp 604} 605 606; Verify that vector types and vector constants including undef elements are transformed too. 607 608define <3 x i1> @i32_cast_cmp_ne_int_0_sitofp_double_vec(<3 x i32> %i) { 609; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_double_vec( 610; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i32> [[I:%.*]], zeroinitializer 611; CHECK-NEXT: ret <3 x i1> [[CMP]] 612; 613 %f = sitofp <3 x i32> %i to <3 x double> 614 %b = bitcast <3 x double> %f to <3 x i64> 615 %cmp = icmp ne <3 x i64> %b, <i64 0, i64 0, i64 0> 616 ret <3 x i1> %cmp 617} 618 619; TODO: Can we propagate the constant vector with undef element? 620 621define <3 x i1> @i32_cast_cmp_eq_int_0_sitofp_float_vec_undef(<3 x i32> %i) { 622; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_float_vec_undef( 623; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i32> [[I:%.*]], zeroinitializer 624; CHECK-NEXT: ret <3 x i1> [[CMP]] 625; 626 %f = sitofp <3 x i32> %i to <3 x float> 627 %b = bitcast <3 x float> %f to <3 x i32> 628 %cmp = icmp eq <3 x i32> %b, <i32 0, i32 undef, i32 0> 629 ret <3 x i1> %cmp 630} 631 632define <3 x i1> @i64_cast_cmp_slt_int_1_sitofp_half_vec_undef(<3 x i64> %i) { 633; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_half_vec_undef( 634; CHECK-NEXT: [[CMP:%.*]] = icmp slt <3 x i64> [[I:%.*]], <i64 1, i64 1, i64 1> 635; CHECK-NEXT: ret <3 x i1> [[CMP]] 636; 637 %f = sitofp <3 x i64> %i to <3 x half> 638 %b = bitcast <3 x half> %f to <3 x i16> 639 %cmp = icmp slt <3 x i16> %b, <i16 1, i16 undef, i16 1> 640 ret <3 x i1> %cmp 641} 642 643define <3 x i1> @i16_cast_cmp_sgt_int_m1_sitofp_float_vec_undef(<3 x i16> %i) { 644; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_float_vec_undef( 645; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <3 x i16> [[I:%.*]], <i16 -1, i16 -1, i16 -1> 646; CHECK-NEXT: ret <3 x i1> [[CMP]] 647; 648 %f = sitofp <3 x i16> %i to <3 x float> 649 %b = bitcast <3 x float> %f to <3 x i32> 650 %cmp = icmp sgt <3 x i32> %b, <i32 -1, i32 undef, i32 -1> 651 ret <3 x i1> %cmp 652} 653 654; Verify that the various forms of this transform are not applied when the 655; bitcast changes the number of vector elements: 656; icmp (bitcast ([su]itofp X)), Y -> icmp X, Y 657 658define <6 x i1> @i16_cast_cmp_sgt_int_m1_bitcast_vector_num_elements_sitofp(<3 x i16> %i) { 659; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_bitcast_vector_num_elements_sitofp( 660; CHECK-NEXT: [[F:%.*]] = sitofp <3 x i16> [[I:%.*]] to <3 x float> 661; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <6 x i16> 662; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <6 x i16> [[B]], <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> 663; CHECK-NEXT: ret <6 x i1> [[CMP]] 664; 665 %f = sitofp <3 x i16> %i to <3 x float> 666 %b = bitcast <3 x float> %f to <6 x i16> 667 %cmp = icmp sgt <6 x i16> %b, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> 668 ret <6 x i1> %cmp 669} 670 671define i1 @i16_cast_cmp_sgt_int_m1_bitcast_vector_to_scalar_sitofp(<3 x i16> %i) { 672; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_bitcast_vector_to_scalar_sitofp( 673; CHECK-NEXT: [[F:%.*]] = sitofp <3 x i16> [[I:%.*]] to <3 x float> 674; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to i96 675; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i96 [[B]], -1 676; CHECK-NEXT: ret i1 [[CMP]] 677; 678 %f = sitofp <3 x i16> %i to <3 x float> 679 %b = bitcast <3 x float> %f to i96 680 %cmp = icmp sgt i96 %b, -1 681 ret i1 %cmp 682} 683 684 685define <6 x i1> @i16_cast_cmp_eq_int_0_bitcast_vector_num_elements_uitofp(<3 x i16> %i) { 686; CHECK-LABEL: @i16_cast_cmp_eq_int_0_bitcast_vector_num_elements_uitofp( 687; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i16> [[I:%.*]] to <3 x float> 688; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <6 x i16> 689; CHECK-NEXT: [[CMP:%.*]] = icmp eq <6 x i16> [[B]], zeroinitializer 690; CHECK-NEXT: ret <6 x i1> [[CMP]] 691; 692 %f = uitofp <3 x i16> %i to <3 x float> 693 %b = bitcast <3 x float> %f to <6 x i16> 694 %cmp = icmp eq <6 x i16> %b, <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0> 695 ret <6 x i1> %cmp 696} 697 698define i1 @i16_cast_cmp_eq_int_0_bitcast_vector_to_scalar_uitofp(<3 x i16> %i) { 699; CHECK-LABEL: @i16_cast_cmp_eq_int_0_bitcast_vector_to_scalar_uitofp( 700; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i16> [[I:%.*]] to <3 x float> 701; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to i96 702; CHECK-NEXT: [[CMP:%.*]] = icmp eq i96 [[B]], 0 703; CHECK-NEXT: ret i1 [[CMP]] 704; 705 %f = uitofp <3 x i16> %i to <3 x float> 706 %b = bitcast <3 x float> %f to i96 707 %cmp = icmp eq i96 %b, 0 708 ret i1 %cmp 709} 710