1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s 3 4; Select of constants: control flow / conditional moves can always be replaced by logic+math (but may not be worth it?). 5; Test the zeroext/signext variants of each pattern to see if that makes a difference. 6 7; select Cond, 0, 1 --> zext (!Cond) 8 9define i32 @select_0_or_1(i1 %cond) { 10; CHECK-LABEL: select_0_or_1: 11; CHECK: // %bb.0: 12; CHECK-NEXT: mvn w8, w0 13; CHECK-NEXT: and w0, w8, #0x1 14; CHECK-NEXT: ret 15 %sel = select i1 %cond, i32 0, i32 1 16 ret i32 %sel 17} 18 19define i32 @select_0_or_1_zeroext(i1 zeroext %cond) { 20; CHECK-LABEL: select_0_or_1_zeroext: 21; CHECK: // %bb.0: 22; CHECK-NEXT: eor w0, w0, #0x1 23; CHECK-NEXT: ret 24 %sel = select i1 %cond, i32 0, i32 1 25 ret i32 %sel 26} 27 28define i32 @select_0_or_1_signext(i1 signext %cond) { 29; CHECK-LABEL: select_0_or_1_signext: 30; CHECK: // %bb.0: 31; CHECK-NEXT: mvn w8, w0 32; CHECK-NEXT: and w0, w8, #0x1 33; CHECK-NEXT: ret 34 %sel = select i1 %cond, i32 0, i32 1 35 ret i32 %sel 36} 37 38; select Cond, 1, 0 --> zext (Cond) 39 40define i32 @select_1_or_0(i1 %cond) { 41; CHECK-LABEL: select_1_or_0: 42; CHECK: // %bb.0: 43; CHECK-NEXT: and w0, w0, #0x1 44; CHECK-NEXT: ret 45 %sel = select i1 %cond, i32 1, i32 0 46 ret i32 %sel 47} 48 49define i32 @select_1_or_0_zeroext(i1 zeroext %cond) { 50; CHECK-LABEL: select_1_or_0_zeroext: 51; CHECK: // %bb.0: 52; CHECK-NEXT: ret 53 %sel = select i1 %cond, i32 1, i32 0 54 ret i32 %sel 55} 56 57define i32 @select_1_or_0_signext(i1 signext %cond) { 58; CHECK-LABEL: select_1_or_0_signext: 59; CHECK: // %bb.0: 60; CHECK-NEXT: and w0, w0, #0x1 61; CHECK-NEXT: ret 62 %sel = select i1 %cond, i32 1, i32 0 63 ret i32 %sel 64} 65 66; select Cond, 0, -1 --> sext (!Cond) 67 68define i32 @select_0_or_neg1(i1 %cond) { 69; CHECK-LABEL: select_0_or_neg1: 70; CHECK: // %bb.0: 71; CHECK-NEXT: mvn w8, w0 72; CHECK-NEXT: sbfx w0, w8, #0, #1 73; CHECK-NEXT: ret 74 %sel = select i1 %cond, i32 0, i32 -1 75 ret i32 %sel 76} 77 78define i32 @select_0_or_neg1_zeroext(i1 zeroext %cond) { 79; CHECK-LABEL: select_0_or_neg1_zeroext: 80; CHECK: // %bb.0: 81; CHECK-NEXT: mvn w8, w0 82; CHECK-NEXT: sbfx w0, w8, #0, #1 83; CHECK-NEXT: ret 84 %sel = select i1 %cond, i32 0, i32 -1 85 ret i32 %sel 86} 87 88define i32 @select_0_or_neg1_signext(i1 signext %cond) { 89; CHECK-LABEL: select_0_or_neg1_signext: 90; CHECK: // %bb.0: 91; CHECK-NEXT: mvn w0, w0 92; CHECK-NEXT: ret 93 %sel = select i1 %cond, i32 0, i32 -1 94 ret i32 %sel 95} 96 97; select Cond, -1, 0 --> sext (Cond) 98 99define i32 @select_neg1_or_0(i1 %cond) { 100; CHECK-LABEL: select_neg1_or_0: 101; CHECK: // %bb.0: 102; CHECK-NEXT: sbfx w0, w0, #0, #1 103; CHECK-NEXT: ret 104 %sel = select i1 %cond, i32 -1, i32 0 105 ret i32 %sel 106} 107 108define i32 @select_neg1_or_0_zeroext(i1 zeroext %cond) { 109; CHECK-LABEL: select_neg1_or_0_zeroext: 110; CHECK: // %bb.0: 111; CHECK-NEXT: sbfx w0, w0, #0, #1 112; CHECK-NEXT: ret 113 %sel = select i1 %cond, i32 -1, i32 0 114 ret i32 %sel 115} 116 117define i32 @select_neg1_or_0_signext(i1 signext %cond) { 118; CHECK-LABEL: select_neg1_or_0_signext: 119; CHECK: // %bb.0: 120; CHECK-NEXT: ret 121 %sel = select i1 %cond, i32 -1, i32 0 122 ret i32 %sel 123} 124 125; select Cond, C+1, C --> add (zext Cond), C 126 127define i32 @select_Cplus1_C(i1 %cond) { 128; CHECK-LABEL: select_Cplus1_C: 129; CHECK: // %bb.0: 130; CHECK-NEXT: tst w0, #0x1 131; CHECK-NEXT: mov w8, #41 132; CHECK-NEXT: cinc w0, w8, ne 133; CHECK-NEXT: ret 134 %sel = select i1 %cond, i32 42, i32 41 135 ret i32 %sel 136} 137 138define i32 @select_Cplus1_C_zeroext(i1 zeroext %cond) { 139; CHECK-LABEL: select_Cplus1_C_zeroext: 140; CHECK: // %bb.0: 141; CHECK-NEXT: cmp w0, #0 // =0 142; CHECK-NEXT: mov w8, #41 143; CHECK-NEXT: cinc w0, w8, ne 144; CHECK-NEXT: ret 145 %sel = select i1 %cond, i32 42, i32 41 146 ret i32 %sel 147} 148 149define i32 @select_Cplus1_C_signext(i1 signext %cond) { 150; CHECK-LABEL: select_Cplus1_C_signext: 151; CHECK: // %bb.0: 152; CHECK-NEXT: tst w0, #0x1 153; CHECK-NEXT: mov w8, #41 154; CHECK-NEXT: cinc w0, w8, ne 155; CHECK-NEXT: ret 156 %sel = select i1 %cond, i32 42, i32 41 157 ret i32 %sel 158} 159 160; select Cond, C, C+1 --> add (sext Cond), C 161 162define i32 @select_C_Cplus1(i1 %cond) { 163; CHECK-LABEL: select_C_Cplus1: 164; CHECK: // %bb.0: 165; CHECK-NEXT: tst w0, #0x1 166; CHECK-NEXT: mov w8, #41 167; CHECK-NEXT: cinc w0, w8, eq 168; CHECK-NEXT: ret 169 %sel = select i1 %cond, i32 41, i32 42 170 ret i32 %sel 171} 172 173define i32 @select_C_Cplus1_zeroext(i1 zeroext %cond) { 174; CHECK-LABEL: select_C_Cplus1_zeroext: 175; CHECK: // %bb.0: 176; CHECK-NEXT: cmp w0, #0 // =0 177; CHECK-NEXT: mov w8, #41 178; CHECK-NEXT: cinc w0, w8, eq 179; CHECK-NEXT: ret 180 %sel = select i1 %cond, i32 41, i32 42 181 ret i32 %sel 182} 183 184define i32 @select_C_Cplus1_signext(i1 signext %cond) { 185; CHECK-LABEL: select_C_Cplus1_signext: 186; CHECK: // %bb.0: 187; CHECK-NEXT: tst w0, #0x1 188; CHECK-NEXT: mov w8, #41 189; CHECK-NEXT: cinc w0, w8, eq 190; CHECK-NEXT: ret 191 %sel = select i1 %cond, i32 41, i32 42 192 ret i32 %sel 193} 194 195; In general, select of 2 constants could be: 196; select Cond, C1, C2 --> add (mul (zext Cond), C1-C2), C2 --> add (and (sext Cond), C1-C2), C2 197 198define i32 @select_C1_C2(i1 %cond) { 199; CHECK-LABEL: select_C1_C2: 200; CHECK: // %bb.0: 201; CHECK-NEXT: tst w0, #0x1 202; CHECK-NEXT: mov w8, #42 203; CHECK-NEXT: mov w9, #421 204; CHECK-NEXT: csel w0, w9, w8, ne 205; CHECK-NEXT: ret 206 %sel = select i1 %cond, i32 421, i32 42 207 ret i32 %sel 208} 209 210define i32 @select_C1_C2_zeroext(i1 zeroext %cond) { 211; CHECK-LABEL: select_C1_C2_zeroext: 212; CHECK: // %bb.0: 213; CHECK-NEXT: cmp w0, #0 // =0 214; CHECK-NEXT: mov w8, #42 215; CHECK-NEXT: mov w9, #421 216; CHECK-NEXT: csel w0, w9, w8, ne 217; CHECK-NEXT: ret 218 %sel = select i1 %cond, i32 421, i32 42 219 ret i32 %sel 220} 221 222define i32 @select_C1_C2_signext(i1 signext %cond) { 223; CHECK-LABEL: select_C1_C2_signext: 224; CHECK: // %bb.0: 225; CHECK-NEXT: tst w0, #0x1 226; CHECK-NEXT: mov w8, #42 227; CHECK-NEXT: mov w9, #421 228; CHECK-NEXT: csel w0, w9, w8, ne 229; CHECK-NEXT: ret 230 %sel = select i1 %cond, i32 421, i32 42 231 ret i32 %sel 232} 233 234; A binary operator with constant after the select should always get folded into the select. 235 236define i8 @sel_constants_add_constant(i1 %cond) { 237; CHECK-LABEL: sel_constants_add_constant: 238; CHECK: // %bb.0: 239; CHECK-NEXT: tst w0, #0x1 240; CHECK-NEXT: mov w8, #28 241; CHECK-NEXT: csinc w0, w8, wzr, eq 242; CHECK-NEXT: ret 243 %sel = select i1 %cond, i8 -4, i8 23 244 %bo = add i8 %sel, 5 245 ret i8 %bo 246} 247 248define i8 @sel_constants_sub_constant(i1 %cond) { 249; CHECK-LABEL: sel_constants_sub_constant: 250; CHECK: // %bb.0: 251; CHECK-NEXT: tst w0, #0x1 252; CHECK-NEXT: mov w8, #18 253; CHECK-NEXT: mov w9, #-9 254; CHECK-NEXT: csel w0, w9, w8, ne 255; CHECK-NEXT: ret 256 %sel = select i1 %cond, i8 -4, i8 23 257 %bo = sub i8 %sel, 5 258 ret i8 %bo 259} 260 261define i8 @sel_constants_sub_constant_sel_constants(i1 %cond) { 262; CHECK-LABEL: sel_constants_sub_constant_sel_constants: 263; CHECK: // %bb.0: 264; CHECK-NEXT: tst w0, #0x1 265; CHECK-NEXT: mov w8, #2 266; CHECK-NEXT: mov w9, #9 267; CHECK-NEXT: csel w0, w9, w8, ne 268; CHECK-NEXT: ret 269 %sel = select i1 %cond, i8 -4, i8 3 270 %bo = sub i8 5, %sel 271 ret i8 %bo 272} 273 274define i8 @sel_constants_mul_constant(i1 %cond) { 275; CHECK-LABEL: sel_constants_mul_constant: 276; CHECK: // %bb.0: 277; CHECK-NEXT: tst w0, #0x1 278; CHECK-NEXT: mov w8, #115 279; CHECK-NEXT: mov w9, #-20 280; CHECK-NEXT: csel w0, w9, w8, ne 281; CHECK-NEXT: ret 282 %sel = select i1 %cond, i8 -4, i8 23 283 %bo = mul i8 %sel, 5 284 ret i8 %bo 285} 286 287define i8 @sel_constants_sdiv_constant(i1 %cond) { 288; CHECK-LABEL: sel_constants_sdiv_constant: 289; CHECK: // %bb.0: 290; CHECK-NEXT: tst w0, #0x1 291; CHECK-NEXT: mov w8, #4 292; CHECK-NEXT: csel w0, wzr, w8, ne 293; CHECK-NEXT: ret 294 %sel = select i1 %cond, i8 -4, i8 23 295 %bo = sdiv i8 %sel, 5 296 ret i8 %bo 297} 298 299define i8 @sdiv_constant_sel_constants(i1 %cond) { 300; CHECK-LABEL: sdiv_constant_sel_constants: 301; CHECK: // %bb.0: 302; CHECK-NEXT: tst w0, #0x1 303; CHECK-NEXT: mov w8, #5 304; CHECK-NEXT: csel w0, wzr, w8, ne 305; CHECK-NEXT: ret 306 %sel = select i1 %cond, i8 121, i8 23 307 %bo = sdiv i8 120, %sel 308 ret i8 %bo 309} 310 311define i8 @sel_constants_udiv_constant(i1 %cond) { 312; CHECK-LABEL: sel_constants_udiv_constant: 313; CHECK: // %bb.0: 314; CHECK-NEXT: tst w0, #0x1 315; CHECK-NEXT: mov w8, #4 316; CHECK-NEXT: mov w9, #50 317; CHECK-NEXT: csel w0, w9, w8, ne 318; CHECK-NEXT: ret 319 %sel = select i1 %cond, i8 -4, i8 23 320 %bo = udiv i8 %sel, 5 321 ret i8 %bo 322} 323 324define i8 @udiv_constant_sel_constants(i1 %cond) { 325; CHECK-LABEL: udiv_constant_sel_constants: 326; CHECK: // %bb.0: 327; CHECK-NEXT: tst w0, #0x1 328; CHECK-NEXT: mov w8, #5 329; CHECK-NEXT: csel w0, wzr, w8, ne 330; CHECK-NEXT: ret 331 %sel = select i1 %cond, i8 -4, i8 23 332 %bo = udiv i8 120, %sel 333 ret i8 %bo 334} 335 336define i8 @sel_constants_srem_constant(i1 %cond) { 337; CHECK-LABEL: sel_constants_srem_constant: 338; CHECK: // %bb.0: 339; CHECK-NEXT: tst w0, #0x1 340; CHECK-NEXT: mov w8, #-4 341; CHECK-NEXT: cinv w0, w8, eq 342; CHECK-NEXT: ret 343 %sel = select i1 %cond, i8 -4, i8 23 344 %bo = srem i8 %sel, 5 345 ret i8 %bo 346} 347 348define i8 @srem_constant_sel_constants(i1 %cond) { 349; CHECK-LABEL: srem_constant_sel_constants: 350; CHECK: // %bb.0: 351; CHECK-NEXT: tst w0, #0x1 352; CHECK-NEXT: mov w8, #5 353; CHECK-NEXT: mov w9, #120 354; CHECK-NEXT: csel w0, w9, w8, ne 355; CHECK-NEXT: ret 356 %sel = select i1 %cond, i8 121, i8 23 357 %bo = srem i8 120, %sel 358 ret i8 %bo 359} 360 361define i8 @sel_constants_urem_constant(i1 %cond) { 362; CHECK-LABEL: sel_constants_urem_constant: 363; CHECK: // %bb.0: 364; CHECK-NEXT: tst w0, #0x1 365; CHECK-NEXT: mov w8, #2 366; CHECK-NEXT: cinc w0, w8, eq 367; CHECK-NEXT: ret 368 %sel = select i1 %cond, i8 -4, i8 23 369 %bo = urem i8 %sel, 5 370 ret i8 %bo 371} 372 373define i8 @urem_constant_sel_constants(i1 %cond) { 374; CHECK-LABEL: urem_constant_sel_constants: 375; CHECK: // %bb.0: 376; CHECK-NEXT: tst w0, #0x1 377; CHECK-NEXT: mov w8, #5 378; CHECK-NEXT: mov w9, #120 379; CHECK-NEXT: csel w0, w9, w8, ne 380; CHECK-NEXT: ret 381 %sel = select i1 %cond, i8 -4, i8 23 382 %bo = urem i8 120, %sel 383 ret i8 %bo 384} 385 386define i8 @sel_constants_and_constant(i1 %cond) { 387; CHECK-LABEL: sel_constants_and_constant: 388; CHECK: // %bb.0: 389; CHECK-NEXT: tst w0, #0x1 390; CHECK-NEXT: mov w8, #4 391; CHECK-NEXT: cinc w0, w8, eq 392; CHECK-NEXT: ret 393 %sel = select i1 %cond, i8 -4, i8 23 394 %bo = and i8 %sel, 5 395 ret i8 %bo 396} 397 398define i8 @sel_constants_or_constant(i1 %cond) { 399; CHECK-LABEL: sel_constants_or_constant: 400; CHECK: // %bb.0: 401; CHECK-NEXT: tst w0, #0x1 402; CHECK-NEXT: mov w8, #23 403; CHECK-NEXT: mov w9, #-3 404; CHECK-NEXT: csel w0, w9, w8, ne 405; CHECK-NEXT: ret 406 %sel = select i1 %cond, i8 -4, i8 23 407 %bo = or i8 %sel, 5 408 ret i8 %bo 409} 410 411define i8 @sel_constants_xor_constant(i1 %cond) { 412; CHECK-LABEL: sel_constants_xor_constant: 413; CHECK: // %bb.0: 414; CHECK-NEXT: tst w0, #0x1 415; CHECK-NEXT: mov w8, #18 416; CHECK-NEXT: mov w9, #-7 417; CHECK-NEXT: csel w0, w9, w8, ne 418; CHECK-NEXT: ret 419 %sel = select i1 %cond, i8 -4, i8 23 420 %bo = xor i8 %sel, 5 421 ret i8 %bo 422} 423 424define i8 @sel_constants_shl_constant(i1 %cond) { 425; CHECK-LABEL: sel_constants_shl_constant: 426; CHECK: // %bb.0: 427; CHECK-NEXT: tst w0, #0x1 428; CHECK-NEXT: mov w8, #-32 429; CHECK-NEXT: mov w9, #-128 430; CHECK-NEXT: csel w0, w9, w8, ne 431; CHECK-NEXT: ret 432 %sel = select i1 %cond, i8 -4, i8 23 433 %bo = shl i8 %sel, 5 434 ret i8 %bo 435} 436 437define i8 @shl_constant_sel_constants(i1 %cond) { 438; CHECK-LABEL: shl_constant_sel_constants: 439; CHECK: // %bb.0: 440; CHECK-NEXT: tst w0, #0x1 441; CHECK-NEXT: mov w8, #2 442; CHECK-NEXT: cinc x8, x8, eq 443; CHECK-NEXT: mov w9, #1 444; CHECK-NEXT: lsl w0, w9, w8 445; CHECK-NEXT: ret 446 %sel = select i1 %cond, i8 2, i8 3 447 %bo = shl i8 1, %sel 448 ret i8 %bo 449} 450 451define i8 @sel_constants_lshr_constant(i1 %cond) { 452; CHECK-LABEL: sel_constants_lshr_constant: 453; CHECK: // %bb.0: 454; CHECK-NEXT: tst w0, #0x1 455; CHECK-NEXT: mov w8, #7 456; CHECK-NEXT: csel w0, w8, wzr, ne 457; CHECK-NEXT: ret 458 %sel = select i1 %cond, i8 -4, i8 23 459 %bo = lshr i8 %sel, 5 460 ret i8 %bo 461} 462 463define i8 @lshr_constant_sel_constants(i1 %cond) { 464; CHECK-LABEL: lshr_constant_sel_constants: 465; CHECK: // %bb.0: 466; CHECK-NEXT: tst w0, #0x1 467; CHECK-NEXT: mov w8, #2 468; CHECK-NEXT: cinc x8, x8, eq 469; CHECK-NEXT: mov w9, #64 470; CHECK-NEXT: lsr w0, w9, w8 471; CHECK-NEXT: ret 472 %sel = select i1 %cond, i8 2, i8 3 473 %bo = lshr i8 64, %sel 474 ret i8 %bo 475} 476 477 478define i8 @sel_constants_ashr_constant(i1 %cond) { 479; CHECK-LABEL: sel_constants_ashr_constant: 480; CHECK: // %bb.0: 481; CHECK-NEXT: sbfx w0, w0, #0, #1 482; CHECK-NEXT: ret 483 %sel = select i1 %cond, i8 -4, i8 23 484 %bo = ashr i8 %sel, 5 485 ret i8 %bo 486} 487 488define i8 @ashr_constant_sel_constants(i1 %cond) { 489; CHECK-LABEL: ashr_constant_sel_constants: 490; CHECK: // %bb.0: 491; CHECK-NEXT: tst w0, #0x1 492; CHECK-NEXT: mov w8, #2 493; CHECK-NEXT: cinc x8, x8, eq 494; CHECK-NEXT: mov w9, #-128 495; CHECK-NEXT: asr w0, w9, w8 496; CHECK-NEXT: ret 497 %sel = select i1 %cond, i8 2, i8 3 498 %bo = ashr i8 128, %sel 499 ret i8 %bo 500} 501 502define double @sel_constants_fadd_constant(i1 %cond) { 503; CHECK-LABEL: sel_constants_fadd_constant: 504; CHECK: // %bb.0: 505; CHECK-NEXT: adrp x8, .LCPI42_0 506; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI42_0] 507; CHECK-NEXT: mov x8, #7378697629483820646 508; CHECK-NEXT: movk x8, #16444, lsl #48 509; CHECK-NEXT: tst w0, #0x1 510; CHECK-NEXT: fmov d1, x8 511; CHECK-NEXT: fcsel d0, d0, d1, ne 512; CHECK-NEXT: ret 513 %sel = select i1 %cond, double -4.0, double 23.3 514 %bo = fadd double %sel, 5.1 515 ret double %bo 516} 517 518define double @sel_constants_fsub_constant(i1 %cond) { 519; CHECK-LABEL: sel_constants_fsub_constant: 520; CHECK: // %bb.0: 521; CHECK-NEXT: adrp x8, .LCPI43_0 522; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI43_0] 523; CHECK-NEXT: mov x8, #3689348814741910323 524; CHECK-NEXT: movk x8, #49186, lsl #48 525; CHECK-NEXT: tst w0, #0x1 526; CHECK-NEXT: fmov d1, x8 527; CHECK-NEXT: fcsel d0, d1, d0, ne 528; CHECK-NEXT: ret 529 %sel = select i1 %cond, double -4.0, double 23.3 530 %bo = fsub double %sel, 5.1 531 ret double %bo 532} 533 534define double @fsub_constant_sel_constants(i1 %cond) { 535; CHECK-LABEL: fsub_constant_sel_constants: 536; CHECK: // %bb.0: 537; CHECK-NEXT: adrp x8, .LCPI44_0 538; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI44_0] 539; CHECK-NEXT: mov x8, #3689348814741910323 540; CHECK-NEXT: movk x8, #16418, lsl #48 541; CHECK-NEXT: tst w0, #0x1 542; CHECK-NEXT: fmov d1, x8 543; CHECK-NEXT: fcsel d0, d1, d0, ne 544; CHECK-NEXT: ret 545 %sel = select i1 %cond, double -4.0, double 23.3 546 %bo = fsub double 5.1, %sel 547 ret double %bo 548} 549 550define double @sel_constants_fmul_constant(i1 %cond) { 551; CHECK-LABEL: sel_constants_fmul_constant: 552; CHECK: // %bb.0: 553; CHECK-NEXT: adrp x8, .LCPI45_0 554; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI45_0] 555; CHECK-NEXT: mov x8, #7378697629483820646 556; CHECK-NEXT: movk x8, #49204, lsl #48 557; CHECK-NEXT: tst w0, #0x1 558; CHECK-NEXT: fmov d1, x8 559; CHECK-NEXT: fcsel d0, d1, d0, ne 560; CHECK-NEXT: ret 561 %sel = select i1 %cond, double -4.0, double 23.3 562 %bo = fmul double %sel, 5.1 563 ret double %bo 564} 565 566define double @sel_constants_fdiv_constant(i1 %cond) { 567; CHECK-LABEL: sel_constants_fdiv_constant: 568; CHECK: // %bb.0: 569; CHECK-NEXT: adrp x8, .LCPI46_0 570; CHECK-NEXT: adrp x9, .LCPI46_1 571; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI46_0] 572; CHECK-NEXT: ldr d1, [x9, :lo12:.LCPI46_1] 573; CHECK-NEXT: tst w0, #0x1 574; CHECK-NEXT: fcsel d0, d1, d0, ne 575; CHECK-NEXT: ret 576 %sel = select i1 %cond, double -4.0, double 23.3 577 %bo = fdiv double %sel, 5.1 578 ret double %bo 579} 580 581define double @fdiv_constant_sel_constants(i1 %cond) { 582; CHECK-LABEL: fdiv_constant_sel_constants: 583; CHECK: // %bb.0: 584; CHECK-NEXT: adrp x8, .LCPI47_0 585; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI47_0] 586; CHECK-NEXT: mov x8, #7378697629483820646 587; CHECK-NEXT: movk x8, #49140, lsl #48 588; CHECK-NEXT: tst w0, #0x1 589; CHECK-NEXT: fmov d1, x8 590; CHECK-NEXT: fcsel d0, d1, d0, ne 591; CHECK-NEXT: ret 592 %sel = select i1 %cond, double -4.0, double 23.3 593 %bo = fdiv double 5.1, %sel 594 ret double %bo 595} 596 597define double @sel_constants_frem_constant(i1 %cond) { 598; CHECK-LABEL: sel_constants_frem_constant: 599; CHECK: // %bb.0: 600; CHECK-NEXT: adrp x8, .LCPI48_0 601; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI48_0] 602; CHECK-NEXT: tst w0, #0x1 603; CHECK-NEXT: fmov d1, #-4.00000000 604; CHECK-NEXT: fcsel d0, d1, d0, ne 605; CHECK-NEXT: ret 606 %sel = select i1 %cond, double -4.0, double 23.3 607 %bo = frem double %sel, 5.1 608 ret double %bo 609} 610 611define double @frem_constant_sel_constants(i1 %cond) { 612; CHECK-LABEL: frem_constant_sel_constants: 613; CHECK: // %bb.0: 614; CHECK-NEXT: adrp x8, .LCPI49_0 615; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI49_0] 616; CHECK-NEXT: mov x8, #7378697629483820646 617; CHECK-NEXT: movk x8, #16404, lsl #48 618; CHECK-NEXT: tst w0, #0x1 619; CHECK-NEXT: fmov d1, x8 620; CHECK-NEXT: fcsel d0, d0, d1, ne 621; CHECK-NEXT: ret 622 %sel = select i1 %cond, double -4.0, double 23.3 623 %bo = frem double 5.1, %sel 624 ret double %bo 625} 626