1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=powerpc64le-unknown-unknown -verify-machineinstrs -mattr=+isel | FileCheck %s --check-prefix=ALL --check-prefix=ISEL 3; RUN: llc < %s -mtriple=powerpc64le-unknown-unknown -verify-machineinstrs -mattr=-isel | FileCheck %s --check-prefix=ALL --check-prefix=NO_ISEL 4 5; Select of constants: control flow / conditional moves can always be replaced by logic+math (but may not be worth it?). 6; Test the zeroext/signext variants of each pattern to see if that makes a difference. 7 8; select Cond, 0, 1 --> zext (!Cond) 9 10define i32 @select_0_or_1(i1 %cond) { 11; ALL-LABEL: select_0_or_1: 12; ALL: # %bb.0: 13; ALL-NEXT: not 3, 3 14; ALL-NEXT: clrldi 3, 3, 63 15; ALL-NEXT: blr 16 %sel = select i1 %cond, i32 0, i32 1 17 ret i32 %sel 18} 19 20define i32 @select_0_or_1_zeroext(i1 zeroext %cond) { 21; ALL-LABEL: select_0_or_1_zeroext: 22; ALL: # %bb.0: 23; ALL-NEXT: xori 3, 3, 1 24; ALL-NEXT: blr 25 %sel = select i1 %cond, i32 0, i32 1 26 ret i32 %sel 27} 28 29define i32 @select_0_or_1_signext(i1 signext %cond) { 30; ALL-LABEL: select_0_or_1_signext: 31; ALL: # %bb.0: 32; ALL-NEXT: not 3, 3 33; ALL-NEXT: clrldi 3, 3, 63 34; ALL-NEXT: blr 35 %sel = select i1 %cond, i32 0, i32 1 36 ret i32 %sel 37} 38 39; select Cond, 1, 0 --> zext (Cond) 40 41define i32 @select_1_or_0(i1 %cond) { 42; ALL-LABEL: select_1_or_0: 43; ALL: # %bb.0: 44; ALL-NEXT: clrldi 3, 3, 63 45; ALL-NEXT: blr 46 %sel = select i1 %cond, i32 1, i32 0 47 ret i32 %sel 48} 49 50define i32 @select_1_or_0_zeroext(i1 zeroext %cond) { 51; ALL-LABEL: select_1_or_0_zeroext: 52; ALL: # %bb.0: 53; ALL-NEXT: blr 54 %sel = select i1 %cond, i32 1, i32 0 55 ret i32 %sel 56} 57 58define i32 @select_1_or_0_signext(i1 signext %cond) { 59; ALL-LABEL: select_1_or_0_signext: 60; ALL: # %bb.0: 61; ALL-NEXT: clrldi 3, 3, 63 62; ALL-NEXT: blr 63 %sel = select i1 %cond, i32 1, i32 0 64 ret i32 %sel 65} 66 67; select Cond, 0, -1 --> sext (!Cond) 68 69define i32 @select_0_or_neg1(i1 %cond) { 70; ALL-LABEL: select_0_or_neg1: 71; ALL: # %bb.0: 72; ALL-NEXT: not 3, 3 73; ALL-NEXT: clrldi 3, 3, 63 74; ALL-NEXT: neg 3, 3 75; ALL-NEXT: blr 76 %sel = select i1 %cond, i32 0, i32 -1 77 ret i32 %sel 78} 79 80define i32 @select_0_or_neg1_zeroext(i1 zeroext %cond) { 81; ALL-LABEL: select_0_or_neg1_zeroext: 82; ALL: # %bb.0: 83; ALL-NEXT: xori 3, 3, 1 84; ALL-NEXT: neg 3, 3 85; ALL-NEXT: blr 86 %sel = select i1 %cond, i32 0, i32 -1 87 ret i32 %sel 88} 89 90define i32 @select_0_or_neg1_signext(i1 signext %cond) { 91; ALL-LABEL: select_0_or_neg1_signext: 92; ALL: # %bb.0: 93; ALL-NEXT: not 3, 3 94; ALL-NEXT: blr 95 %sel = select i1 %cond, i32 0, i32 -1 96 ret i32 %sel 97} 98 99; select Cond, -1, 0 --> sext (Cond) 100 101define i32 @select_neg1_or_0(i1 %cond) { 102; ALL-LABEL: select_neg1_or_0: 103; ALL: # %bb.0: 104; ALL-NEXT: clrldi 3, 3, 63 105; ALL-NEXT: neg 3, 3 106; ALL-NEXT: blr 107 %sel = select i1 %cond, i32 -1, i32 0 108 ret i32 %sel 109} 110 111define i32 @select_neg1_or_0_zeroext(i1 zeroext %cond) { 112; ALL-LABEL: select_neg1_or_0_zeroext: 113; ALL: # %bb.0: 114; ALL-NEXT: neg 3, 3 115; ALL-NEXT: blr 116 %sel = select i1 %cond, i32 -1, i32 0 117 ret i32 %sel 118} 119 120define i32 @select_neg1_or_0_signext(i1 signext %cond) { 121; ALL-LABEL: select_neg1_or_0_signext: 122; ALL: # %bb.0: 123; ALL-NEXT: blr 124 %sel = select i1 %cond, i32 -1, i32 0 125 ret i32 %sel 126} 127 128; select Cond, C+1, C --> add (zext Cond), C 129 130define i32 @select_Cplus1_C(i1 %cond) { 131; ALL-LABEL: select_Cplus1_C: 132; ALL: # %bb.0: 133; ALL-NEXT: clrldi 3, 3, 63 134; ALL-NEXT: addi 3, 3, 41 135; ALL-NEXT: blr 136 %sel = select i1 %cond, i32 42, i32 41 137 ret i32 %sel 138} 139 140define i32 @select_Cplus1_C_zeroext(i1 zeroext %cond) { 141; ALL-LABEL: select_Cplus1_C_zeroext: 142; ALL: # %bb.0: 143; ALL-NEXT: addi 3, 3, 41 144; ALL-NEXT: blr 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; ALL-LABEL: select_Cplus1_C_signext: 151; ALL: # %bb.0: 152; ALL-NEXT: subfic 3, 3, 41 153; ALL-NEXT: blr 154 %sel = select i1 %cond, i32 42, i32 41 155 ret i32 %sel 156} 157 158; select Cond, C, C+1 --> add (sext Cond), C 159 160define i32 @select_C_Cplus1(i1 %cond) { 161; ALL-LABEL: select_C_Cplus1: 162; ALL: # %bb.0: 163; ALL-NEXT: clrldi 3, 3, 63 164; ALL-NEXT: subfic 3, 3, 42 165; ALL-NEXT: blr 166 %sel = select i1 %cond, i32 41, i32 42 167 ret i32 %sel 168} 169 170define i32 @select_C_Cplus1_zeroext(i1 zeroext %cond) { 171; ALL-LABEL: select_C_Cplus1_zeroext: 172; ALL: # %bb.0: 173; ALL-NEXT: subfic 3, 3, 42 174; ALL-NEXT: blr 175 %sel = select i1 %cond, i32 41, i32 42 176 ret i32 %sel 177} 178 179define i32 @select_C_Cplus1_signext(i1 signext %cond) { 180; ALL-LABEL: select_C_Cplus1_signext: 181; ALL: # %bb.0: 182; ALL-NEXT: addi 3, 3, 42 183; ALL-NEXT: blr 184 %sel = select i1 %cond, i32 41, i32 42 185 ret i32 %sel 186} 187 188; In general, select of 2 constants could be: 189; select Cond, C1, C2 --> add (mul (zext Cond), C1-C2), C2 --> add (and (sext Cond), C1-C2), C2 190 191define i32 @select_C1_C2(i1 %cond) { 192; ISEL-LABEL: select_C1_C2: 193; ISEL: # %bb.0: 194; ISEL-NEXT: andi. 3, 3, 1 195; ISEL-NEXT: li 4, 421 196; ISEL-NEXT: li 3, 42 197; ISEL-NEXT: iselgt 3, 4, 3 198; ISEL-NEXT: blr 199; 200; NO_ISEL-LABEL: select_C1_C2: 201; NO_ISEL: # %bb.0: 202; NO_ISEL-NEXT: andi. 3, 3, 1 203; NO_ISEL-NEXT: li 4, 421 204; NO_ISEL-NEXT: li 3, 42 205; NO_ISEL-NEXT: bc 12, 1, .LBB18_1 206; NO_ISEL-NEXT: blr 207; NO_ISEL-NEXT: .LBB18_1: 208; NO_ISEL-NEXT: addi 3, 4, 0 209; NO_ISEL-NEXT: blr 210 %sel = select i1 %cond, i32 421, i32 42 211 ret i32 %sel 212} 213 214define i32 @select_C1_C2_zeroext(i1 zeroext %cond) { 215; ISEL-LABEL: select_C1_C2_zeroext: 216; ISEL: # %bb.0: 217; ISEL-NEXT: andi. 3, 3, 1 218; ISEL-NEXT: li 4, 421 219; ISEL-NEXT: li 3, 42 220; ISEL-NEXT: iselgt 3, 4, 3 221; ISEL-NEXT: blr 222; 223; NO_ISEL-LABEL: select_C1_C2_zeroext: 224; NO_ISEL: # %bb.0: 225; NO_ISEL-NEXT: andi. 3, 3, 1 226; NO_ISEL-NEXT: li 4, 421 227; NO_ISEL-NEXT: li 3, 42 228; NO_ISEL-NEXT: bc 12, 1, .LBB19_1 229; NO_ISEL-NEXT: blr 230; NO_ISEL-NEXT: .LBB19_1: 231; NO_ISEL-NEXT: addi 3, 4, 0 232; NO_ISEL-NEXT: blr 233 %sel = select i1 %cond, i32 421, i32 42 234 ret i32 %sel 235} 236 237define i32 @select_C1_C2_signext(i1 signext %cond) { 238; ISEL-LABEL: select_C1_C2_signext: 239; ISEL: # %bb.0: 240; ISEL-NEXT: andi. 3, 3, 1 241; ISEL-NEXT: li 4, 421 242; ISEL-NEXT: li 3, 42 243; ISEL-NEXT: iselgt 3, 4, 3 244; ISEL-NEXT: blr 245; 246; NO_ISEL-LABEL: select_C1_C2_signext: 247; NO_ISEL: # %bb.0: 248; NO_ISEL-NEXT: andi. 3, 3, 1 249; NO_ISEL-NEXT: li 4, 421 250; NO_ISEL-NEXT: li 3, 42 251; NO_ISEL-NEXT: bc 12, 1, .LBB20_1 252; NO_ISEL-NEXT: blr 253; NO_ISEL-NEXT: .LBB20_1: 254; NO_ISEL-NEXT: addi 3, 4, 0 255; NO_ISEL-NEXT: blr 256 %sel = select i1 %cond, i32 421, i32 42 257 ret i32 %sel 258} 259 260; A binary operator with constant after the select should always get folded into the select. 261 262define i8 @sel_constants_add_constant(i1 %cond) { 263; ISEL-LABEL: sel_constants_add_constant: 264; ISEL: # %bb.0: 265; ISEL-NEXT: andi. 3, 3, 1 266; ISEL-NEXT: li 4, 1 267; ISEL-NEXT: li 3, 28 268; ISEL-NEXT: iselgt 3, 4, 3 269; ISEL-NEXT: blr 270; 271; NO_ISEL-LABEL: sel_constants_add_constant: 272; NO_ISEL: # %bb.0: 273; NO_ISEL-NEXT: andi. 3, 3, 1 274; NO_ISEL-NEXT: li 4, 1 275; NO_ISEL-NEXT: li 3, 28 276; NO_ISEL-NEXT: bc 12, 1, .LBB21_1 277; NO_ISEL-NEXT: blr 278; NO_ISEL-NEXT: .LBB21_1: 279; NO_ISEL-NEXT: addi 3, 4, 0 280; NO_ISEL-NEXT: blr 281 %sel = select i1 %cond, i8 -4, i8 23 282 %bo = add i8 %sel, 5 283 ret i8 %bo 284} 285 286define i8 @sel_constants_sub_constant(i1 %cond) { 287; ISEL-LABEL: sel_constants_sub_constant: 288; ISEL: # %bb.0: 289; ISEL-NEXT: andi. 3, 3, 1 290; ISEL-NEXT: li 4, -9 291; ISEL-NEXT: li 3, 18 292; ISEL-NEXT: iselgt 3, 4, 3 293; ISEL-NEXT: blr 294; 295; NO_ISEL-LABEL: sel_constants_sub_constant: 296; NO_ISEL: # %bb.0: 297; NO_ISEL-NEXT: andi. 3, 3, 1 298; NO_ISEL-NEXT: li 4, -9 299; NO_ISEL-NEXT: li 3, 18 300; NO_ISEL-NEXT: bc 12, 1, .LBB22_1 301; NO_ISEL-NEXT: blr 302; NO_ISEL-NEXT: .LBB22_1: 303; NO_ISEL-NEXT: addi 3, 4, 0 304; NO_ISEL-NEXT: blr 305 %sel = select i1 %cond, i8 -4, i8 23 306 %bo = sub i8 %sel, 5 307 ret i8 %bo 308} 309 310define i8 @sel_constants_sub_constant_sel_constants(i1 %cond) { 311; ISEL-LABEL: sel_constants_sub_constant_sel_constants: 312; ISEL: # %bb.0: 313; ISEL-NEXT: andi. 3, 3, 1 314; ISEL-NEXT: li 4, 9 315; ISEL-NEXT: li 3, 2 316; ISEL-NEXT: iselgt 3, 4, 3 317; ISEL-NEXT: blr 318; 319; NO_ISEL-LABEL: sel_constants_sub_constant_sel_constants: 320; NO_ISEL: # %bb.0: 321; NO_ISEL-NEXT: andi. 3, 3, 1 322; NO_ISEL-NEXT: li 4, 9 323; NO_ISEL-NEXT: li 3, 2 324; NO_ISEL-NEXT: bc 12, 1, .LBB23_1 325; NO_ISEL-NEXT: blr 326; NO_ISEL-NEXT: .LBB23_1: 327; NO_ISEL-NEXT: addi 3, 4, 0 328; NO_ISEL-NEXT: blr 329 %sel = select i1 %cond, i8 -4, i8 3 330 %bo = sub i8 5, %sel 331 ret i8 %bo 332} 333 334define i8 @sel_constants_mul_constant(i1 %cond) { 335; ISEL-LABEL: sel_constants_mul_constant: 336; ISEL: # %bb.0: 337; ISEL-NEXT: andi. 3, 3, 1 338; ISEL-NEXT: li 4, -20 339; ISEL-NEXT: li 3, 115 340; ISEL-NEXT: iselgt 3, 4, 3 341; ISEL-NEXT: blr 342; 343; NO_ISEL-LABEL: sel_constants_mul_constant: 344; NO_ISEL: # %bb.0: 345; NO_ISEL-NEXT: andi. 3, 3, 1 346; NO_ISEL-NEXT: li 4, -20 347; NO_ISEL-NEXT: li 3, 115 348; NO_ISEL-NEXT: bc 12, 1, .LBB24_1 349; NO_ISEL-NEXT: blr 350; NO_ISEL-NEXT: .LBB24_1: 351; NO_ISEL-NEXT: addi 3, 4, 0 352; NO_ISEL-NEXT: blr 353 %sel = select i1 %cond, i8 -4, i8 23 354 %bo = mul i8 %sel, 5 355 ret i8 %bo 356} 357 358define i8 @sel_constants_sdiv_constant(i1 %cond) { 359; ISEL-LABEL: sel_constants_sdiv_constant: 360; ISEL: # %bb.0: 361; ISEL-NEXT: andi. 3, 3, 1 362; ISEL-NEXT: li 3, 4 363; ISEL-NEXT: iselgt 3, 0, 3 364; ISEL-NEXT: blr 365; 366; NO_ISEL-LABEL: sel_constants_sdiv_constant: 367; NO_ISEL: # %bb.0: 368; NO_ISEL-NEXT: andi. 3, 3, 1 369; NO_ISEL-NEXT: li 3, 4 370; NO_ISEL-NEXT: bc 12, 1, .LBB25_1 371; NO_ISEL-NEXT: blr 372; NO_ISEL-NEXT: .LBB25_1: 373; NO_ISEL-NEXT: li 3, 0 374; NO_ISEL-NEXT: blr 375 %sel = select i1 %cond, i8 -4, i8 23 376 %bo = sdiv i8 %sel, 5 377 ret i8 %bo 378} 379 380define i8 @sdiv_constant_sel_constants(i1 %cond) { 381; ISEL-LABEL: sdiv_constant_sel_constants: 382; ISEL: # %bb.0: 383; ISEL-NEXT: andi. 3, 3, 1 384; ISEL-NEXT: li 3, 5 385; ISEL-NEXT: iselgt 3, 0, 3 386; ISEL-NEXT: blr 387; 388; NO_ISEL-LABEL: sdiv_constant_sel_constants: 389; NO_ISEL: # %bb.0: 390; NO_ISEL-NEXT: andi. 3, 3, 1 391; NO_ISEL-NEXT: li 3, 5 392; NO_ISEL-NEXT: bc 12, 1, .LBB26_1 393; NO_ISEL-NEXT: blr 394; NO_ISEL-NEXT: .LBB26_1: 395; NO_ISEL-NEXT: li 3, 0 396; NO_ISEL-NEXT: blr 397 %sel = select i1 %cond, i8 121, i8 23 398 %bo = sdiv i8 120, %sel 399 ret i8 %bo 400} 401 402define i8 @sel_constants_udiv_constant(i1 %cond) { 403; ISEL-LABEL: sel_constants_udiv_constant: 404; ISEL: # %bb.0: 405; ISEL-NEXT: andi. 3, 3, 1 406; ISEL-NEXT: li 4, 50 407; ISEL-NEXT: li 3, 4 408; ISEL-NEXT: iselgt 3, 4, 3 409; ISEL-NEXT: blr 410; 411; NO_ISEL-LABEL: sel_constants_udiv_constant: 412; NO_ISEL: # %bb.0: 413; NO_ISEL-NEXT: andi. 3, 3, 1 414; NO_ISEL-NEXT: li 4, 50 415; NO_ISEL-NEXT: li 3, 4 416; NO_ISEL-NEXT: bc 12, 1, .LBB27_1 417; NO_ISEL-NEXT: blr 418; NO_ISEL-NEXT: .LBB27_1: 419; NO_ISEL-NEXT: addi 3, 4, 0 420; NO_ISEL-NEXT: blr 421 %sel = select i1 %cond, i8 -4, i8 23 422 %bo = udiv i8 %sel, 5 423 ret i8 %bo 424} 425 426define i8 @udiv_constant_sel_constants(i1 %cond) { 427; ISEL-LABEL: udiv_constant_sel_constants: 428; ISEL: # %bb.0: 429; ISEL-NEXT: andi. 3, 3, 1 430; ISEL-NEXT: li 3, 5 431; ISEL-NEXT: iselgt 3, 0, 3 432; ISEL-NEXT: blr 433; 434; NO_ISEL-LABEL: udiv_constant_sel_constants: 435; NO_ISEL: # %bb.0: 436; NO_ISEL-NEXT: andi. 3, 3, 1 437; NO_ISEL-NEXT: li 3, 5 438; NO_ISEL-NEXT: bc 12, 1, .LBB28_1 439; NO_ISEL-NEXT: blr 440; NO_ISEL-NEXT: .LBB28_1: 441; NO_ISEL-NEXT: li 3, 0 442; NO_ISEL-NEXT: blr 443 %sel = select i1 %cond, i8 -4, i8 23 444 %bo = udiv i8 120, %sel 445 ret i8 %bo 446} 447 448define i8 @sel_constants_srem_constant(i1 %cond) { 449; ISEL-LABEL: sel_constants_srem_constant: 450; ISEL: # %bb.0: 451; ISEL-NEXT: andi. 3, 3, 1 452; ISEL-NEXT: li 4, -4 453; ISEL-NEXT: li 3, 3 454; ISEL-NEXT: iselgt 3, 4, 3 455; ISEL-NEXT: blr 456; 457; NO_ISEL-LABEL: sel_constants_srem_constant: 458; NO_ISEL: # %bb.0: 459; NO_ISEL-NEXT: andi. 3, 3, 1 460; NO_ISEL-NEXT: li 4, -4 461; NO_ISEL-NEXT: li 3, 3 462; NO_ISEL-NEXT: bc 12, 1, .LBB29_1 463; NO_ISEL-NEXT: blr 464; NO_ISEL-NEXT: .LBB29_1: 465; NO_ISEL-NEXT: addi 3, 4, 0 466; NO_ISEL-NEXT: blr 467 %sel = select i1 %cond, i8 -4, i8 23 468 %bo = srem i8 %sel, 5 469 ret i8 %bo 470} 471 472define i8 @srem_constant_sel_constants(i1 %cond) { 473; ISEL-LABEL: srem_constant_sel_constants: 474; ISEL: # %bb.0: 475; ISEL-NEXT: andi. 3, 3, 1 476; ISEL-NEXT: li 4, 120 477; ISEL-NEXT: li 3, 5 478; ISEL-NEXT: iselgt 3, 4, 3 479; ISEL-NEXT: blr 480; 481; NO_ISEL-LABEL: srem_constant_sel_constants: 482; NO_ISEL: # %bb.0: 483; NO_ISEL-NEXT: andi. 3, 3, 1 484; NO_ISEL-NEXT: li 4, 120 485; NO_ISEL-NEXT: li 3, 5 486; NO_ISEL-NEXT: bc 12, 1, .LBB30_1 487; NO_ISEL-NEXT: blr 488; NO_ISEL-NEXT: .LBB30_1: 489; NO_ISEL-NEXT: addi 3, 4, 0 490; NO_ISEL-NEXT: blr 491 %sel = select i1 %cond, i8 121, i8 23 492 %bo = srem i8 120, %sel 493 ret i8 %bo 494} 495 496define i8 @sel_constants_urem_constant(i1 %cond) { 497; ALL-LABEL: sel_constants_urem_constant: 498; ALL: # %bb.0: 499; ALL-NEXT: clrldi 3, 3, 63 500; ALL-NEXT: subfic 3, 3, 3 501; ALL-NEXT: blr 502 %sel = select i1 %cond, i8 -4, i8 23 503 %bo = urem i8 %sel, 5 504 ret i8 %bo 505} 506 507define i8 @urem_constant_sel_constants(i1 %cond) { 508; ISEL-LABEL: urem_constant_sel_constants: 509; ISEL: # %bb.0: 510; ISEL-NEXT: andi. 3, 3, 1 511; ISEL-NEXT: li 4, 120 512; ISEL-NEXT: li 3, 5 513; ISEL-NEXT: iselgt 3, 4, 3 514; ISEL-NEXT: blr 515; 516; NO_ISEL-LABEL: urem_constant_sel_constants: 517; NO_ISEL: # %bb.0: 518; NO_ISEL-NEXT: andi. 3, 3, 1 519; NO_ISEL-NEXT: li 4, 120 520; NO_ISEL-NEXT: li 3, 5 521; NO_ISEL-NEXT: bc 12, 1, .LBB32_1 522; NO_ISEL-NEXT: blr 523; NO_ISEL-NEXT: .LBB32_1: 524; NO_ISEL-NEXT: addi 3, 4, 0 525; NO_ISEL-NEXT: blr 526 %sel = select i1 %cond, i8 -4, i8 23 527 %bo = urem i8 120, %sel 528 ret i8 %bo 529} 530 531define i8 @sel_constants_and_constant(i1 %cond) { 532; ALL-LABEL: sel_constants_and_constant: 533; ALL: # %bb.0: 534; ALL-NEXT: clrldi 3, 3, 63 535; ALL-NEXT: subfic 3, 3, 5 536; ALL-NEXT: blr 537 %sel = select i1 %cond, i8 -4, i8 23 538 %bo = and i8 %sel, 5 539 ret i8 %bo 540} 541 542define i8 @sel_constants_or_constant(i1 %cond) { 543; ISEL-LABEL: sel_constants_or_constant: 544; ISEL: # %bb.0: 545; ISEL-NEXT: andi. 3, 3, 1 546; ISEL-NEXT: li 4, -3 547; ISEL-NEXT: li 3, 23 548; ISEL-NEXT: iselgt 3, 4, 3 549; ISEL-NEXT: blr 550; 551; NO_ISEL-LABEL: sel_constants_or_constant: 552; NO_ISEL: # %bb.0: 553; NO_ISEL-NEXT: andi. 3, 3, 1 554; NO_ISEL-NEXT: li 4, -3 555; NO_ISEL-NEXT: li 3, 23 556; NO_ISEL-NEXT: bc 12, 1, .LBB34_1 557; NO_ISEL-NEXT: blr 558; NO_ISEL-NEXT: .LBB34_1: 559; NO_ISEL-NEXT: addi 3, 4, 0 560; NO_ISEL-NEXT: blr 561 %sel = select i1 %cond, i8 -4, i8 23 562 %bo = or i8 %sel, 5 563 ret i8 %bo 564} 565 566define i8 @sel_constants_xor_constant(i1 %cond) { 567; ISEL-LABEL: sel_constants_xor_constant: 568; ISEL: # %bb.0: 569; ISEL-NEXT: andi. 3, 3, 1 570; ISEL-NEXT: li 4, -7 571; ISEL-NEXT: li 3, 18 572; ISEL-NEXT: iselgt 3, 4, 3 573; ISEL-NEXT: blr 574; 575; NO_ISEL-LABEL: sel_constants_xor_constant: 576; NO_ISEL: # %bb.0: 577; NO_ISEL-NEXT: andi. 3, 3, 1 578; NO_ISEL-NEXT: li 4, -7 579; NO_ISEL-NEXT: li 3, 18 580; NO_ISEL-NEXT: bc 12, 1, .LBB35_1 581; NO_ISEL-NEXT: blr 582; NO_ISEL-NEXT: .LBB35_1: 583; NO_ISEL-NEXT: addi 3, 4, 0 584; NO_ISEL-NEXT: blr 585 %sel = select i1 %cond, i8 -4, i8 23 586 %bo = xor i8 %sel, 5 587 ret i8 %bo 588} 589 590define i8 @sel_constants_shl_constant(i1 %cond) { 591; ISEL-LABEL: sel_constants_shl_constant: 592; ISEL: # %bb.0: 593; ISEL-NEXT: andi. 3, 3, 1 594; ISEL-NEXT: li 4, -128 595; ISEL-NEXT: li 3, -32 596; ISEL-NEXT: iselgt 3, 4, 3 597; ISEL-NEXT: blr 598; 599; NO_ISEL-LABEL: sel_constants_shl_constant: 600; NO_ISEL: # %bb.0: 601; NO_ISEL-NEXT: andi. 3, 3, 1 602; NO_ISEL-NEXT: li 4, -128 603; NO_ISEL-NEXT: li 3, -32 604; NO_ISEL-NEXT: bc 12, 1, .LBB36_1 605; NO_ISEL-NEXT: blr 606; NO_ISEL-NEXT: .LBB36_1: 607; NO_ISEL-NEXT: addi 3, 4, 0 608; NO_ISEL-NEXT: blr 609 %sel = select i1 %cond, i8 -4, i8 23 610 %bo = shl i8 %sel, 5 611 ret i8 %bo 612} 613 614define i8 @shl_constant_sel_constants(i1 %cond) { 615; ALL-LABEL: shl_constant_sel_constants: 616; ALL: # %bb.0: 617; ALL-NEXT: clrlwi 3, 3, 31 618; ALL-NEXT: li 4, 1 619; ALL-NEXT: subfic 3, 3, 3 620; ALL-NEXT: slw 3, 4, 3 621; ALL-NEXT: blr 622 %sel = select i1 %cond, i8 2, i8 3 623 %bo = shl i8 1, %sel 624 ret i8 %bo 625} 626 627define i8 @sel_constants_lshr_constant(i1 %cond) { 628; ISEL-LABEL: sel_constants_lshr_constant: 629; ISEL: # %bb.0: 630; ISEL-NEXT: andi. 3, 3, 1 631; ISEL-NEXT: li 4, 7 632; ISEL-NEXT: li 3, 0 633; ISEL-NEXT: iselgt 3, 4, 3 634; ISEL-NEXT: blr 635; 636; NO_ISEL-LABEL: sel_constants_lshr_constant: 637; NO_ISEL: # %bb.0: 638; NO_ISEL-NEXT: andi. 3, 3, 1 639; NO_ISEL-NEXT: li 4, 7 640; NO_ISEL-NEXT: li 3, 0 641; NO_ISEL-NEXT: bc 12, 1, .LBB38_1 642; NO_ISEL-NEXT: blr 643; NO_ISEL-NEXT: .LBB38_1: 644; NO_ISEL-NEXT: addi 3, 4, 0 645; NO_ISEL-NEXT: blr 646 %sel = select i1 %cond, i8 -4, i8 23 647 %bo = lshr i8 %sel, 5 648 ret i8 %bo 649} 650 651define i8 @lshr_constant_sel_constants(i1 %cond) { 652; ALL-LABEL: lshr_constant_sel_constants: 653; ALL: # %bb.0: 654; ALL-NEXT: clrlwi 3, 3, 31 655; ALL-NEXT: li 4, 64 656; ALL-NEXT: subfic 3, 3, 3 657; ALL-NEXT: srw 3, 4, 3 658; ALL-NEXT: blr 659 %sel = select i1 %cond, i8 2, i8 3 660 %bo = lshr i8 64, %sel 661 ret i8 %bo 662} 663 664 665define i8 @sel_constants_ashr_constant(i1 %cond) { 666; ALL-LABEL: sel_constants_ashr_constant: 667; ALL: # %bb.0: 668; ALL-NEXT: clrldi 3, 3, 63 669; ALL-NEXT: neg 3, 3 670; ALL-NEXT: blr 671 %sel = select i1 %cond, i8 -4, i8 23 672 %bo = ashr i8 %sel, 5 673 ret i8 %bo 674} 675 676define i8 @ashr_constant_sel_constants(i1 %cond) { 677; ALL-LABEL: ashr_constant_sel_constants: 678; ALL: # %bb.0: 679; ALL-NEXT: clrlwi 3, 3, 31 680; ALL-NEXT: li 4, -128 681; ALL-NEXT: subfic 3, 3, 3 682; ALL-NEXT: sraw 3, 4, 3 683; ALL-NEXT: blr 684 %sel = select i1 %cond, i8 2, i8 3 685 %bo = ashr i8 128, %sel 686 ret i8 %bo 687} 688 689define double @sel_constants_fadd_constant(i1 %cond) { 690; ISEL-LABEL: sel_constants_fadd_constant: 691; ISEL: # %bb.0: 692; ISEL-NEXT: andi. 3, 3, 1 693; ISEL-NEXT: addis 4, 2, .LCPI42_0@toc@ha 694; ISEL-NEXT: addis 3, 2, .LCPI42_1@toc@ha 695; ISEL-NEXT: addi 4, 4, .LCPI42_0@toc@l 696; ISEL-NEXT: addi 3, 3, .LCPI42_1@toc@l 697; ISEL-NEXT: iselgt 3, 3, 4 698; ISEL-NEXT: lfdx 1, 0, 3 699; ISEL-NEXT: blr 700; 701; NO_ISEL-LABEL: sel_constants_fadd_constant: 702; NO_ISEL: # %bb.0: 703; NO_ISEL-NEXT: andi. 3, 3, 1 704; NO_ISEL-NEXT: addis 4, 2, .LCPI42_0@toc@ha 705; NO_ISEL-NEXT: addis 3, 2, .LCPI42_1@toc@ha 706; NO_ISEL-NEXT: addi 4, 4, .LCPI42_0@toc@l 707; NO_ISEL-NEXT: addi 3, 3, .LCPI42_1@toc@l 708; NO_ISEL-NEXT: bc 12, 1, .LBB42_2 709; NO_ISEL-NEXT: # %bb.1: 710; NO_ISEL-NEXT: ori 3, 4, 0 711; NO_ISEL-NEXT: b .LBB42_2 712; NO_ISEL-NEXT: .LBB42_2: 713; NO_ISEL-NEXT: lfdx 1, 0, 3 714; NO_ISEL-NEXT: blr 715 %sel = select i1 %cond, double -4.0, double 23.3 716 %bo = fadd double %sel, 5.1 717 ret double %bo 718} 719 720define double @sel_constants_fsub_constant(i1 %cond) { 721; ISEL-LABEL: sel_constants_fsub_constant: 722; ISEL: # %bb.0: 723; ISEL-NEXT: andi. 3, 3, 1 724; ISEL-NEXT: addis 4, 2, .LCPI43_0@toc@ha 725; ISEL-NEXT: addis 3, 2, .LCPI43_1@toc@ha 726; ISEL-NEXT: addi 4, 4, .LCPI43_0@toc@l 727; ISEL-NEXT: addi 3, 3, .LCPI43_1@toc@l 728; ISEL-NEXT: iselgt 3, 3, 4 729; ISEL-NEXT: lfdx 1, 0, 3 730; ISEL-NEXT: blr 731; 732; NO_ISEL-LABEL: sel_constants_fsub_constant: 733; NO_ISEL: # %bb.0: 734; NO_ISEL-NEXT: andi. 3, 3, 1 735; NO_ISEL-NEXT: addis 4, 2, .LCPI43_0@toc@ha 736; NO_ISEL-NEXT: addis 3, 2, .LCPI43_1@toc@ha 737; NO_ISEL-NEXT: addi 4, 4, .LCPI43_0@toc@l 738; NO_ISEL-NEXT: addi 3, 3, .LCPI43_1@toc@l 739; NO_ISEL-NEXT: bc 12, 1, .LBB43_2 740; NO_ISEL-NEXT: # %bb.1: 741; NO_ISEL-NEXT: ori 3, 4, 0 742; NO_ISEL-NEXT: b .LBB43_2 743; NO_ISEL-NEXT: .LBB43_2: 744; NO_ISEL-NEXT: lfdx 1, 0, 3 745; NO_ISEL-NEXT: blr 746 %sel = select i1 %cond, double -4.0, double 23.3 747 %bo = fsub double %sel, 5.1 748 ret double %bo 749} 750 751define double @fsub_constant_sel_constants(i1 %cond) { 752; ISEL-LABEL: fsub_constant_sel_constants: 753; ISEL: # %bb.0: 754; ISEL-NEXT: andi. 3, 3, 1 755; ISEL-NEXT: addis 4, 2, .LCPI44_0@toc@ha 756; ISEL-NEXT: addis 3, 2, .LCPI44_1@toc@ha 757; ISEL-NEXT: addi 4, 4, .LCPI44_0@toc@l 758; ISEL-NEXT: addi 3, 3, .LCPI44_1@toc@l 759; ISEL-NEXT: iselgt 3, 3, 4 760; ISEL-NEXT: lfdx 1, 0, 3 761; ISEL-NEXT: blr 762; 763; NO_ISEL-LABEL: fsub_constant_sel_constants: 764; NO_ISEL: # %bb.0: 765; NO_ISEL-NEXT: andi. 3, 3, 1 766; NO_ISEL-NEXT: addis 4, 2, .LCPI44_0@toc@ha 767; NO_ISEL-NEXT: addis 3, 2, .LCPI44_1@toc@ha 768; NO_ISEL-NEXT: addi 4, 4, .LCPI44_0@toc@l 769; NO_ISEL-NEXT: addi 3, 3, .LCPI44_1@toc@l 770; NO_ISEL-NEXT: bc 12, 1, .LBB44_2 771; NO_ISEL-NEXT: # %bb.1: 772; NO_ISEL-NEXT: ori 3, 4, 0 773; NO_ISEL-NEXT: b .LBB44_2 774; NO_ISEL-NEXT: .LBB44_2: 775; NO_ISEL-NEXT: lfdx 1, 0, 3 776; NO_ISEL-NEXT: blr 777 %sel = select i1 %cond, double -4.0, double 23.3 778 %bo = fsub double 5.1, %sel 779 ret double %bo 780} 781 782define double @sel_constants_fmul_constant(i1 %cond) { 783; ISEL-LABEL: sel_constants_fmul_constant: 784; ISEL: # %bb.0: 785; ISEL-NEXT: andi. 3, 3, 1 786; ISEL-NEXT: addis 4, 2, .LCPI45_0@toc@ha 787; ISEL-NEXT: addis 3, 2, .LCPI45_1@toc@ha 788; ISEL-NEXT: addi 4, 4, .LCPI45_0@toc@l 789; ISEL-NEXT: addi 3, 3, .LCPI45_1@toc@l 790; ISEL-NEXT: iselgt 3, 3, 4 791; ISEL-NEXT: lfdx 1, 0, 3 792; ISEL-NEXT: blr 793; 794; NO_ISEL-LABEL: sel_constants_fmul_constant: 795; NO_ISEL: # %bb.0: 796; NO_ISEL-NEXT: andi. 3, 3, 1 797; NO_ISEL-NEXT: addis 4, 2, .LCPI45_0@toc@ha 798; NO_ISEL-NEXT: addis 3, 2, .LCPI45_1@toc@ha 799; NO_ISEL-NEXT: addi 4, 4, .LCPI45_0@toc@l 800; NO_ISEL-NEXT: addi 3, 3, .LCPI45_1@toc@l 801; NO_ISEL-NEXT: bc 12, 1, .LBB45_2 802; NO_ISEL-NEXT: # %bb.1: 803; NO_ISEL-NEXT: ori 3, 4, 0 804; NO_ISEL-NEXT: b .LBB45_2 805; NO_ISEL-NEXT: .LBB45_2: 806; NO_ISEL-NEXT: lfdx 1, 0, 3 807; NO_ISEL-NEXT: blr 808 %sel = select i1 %cond, double -4.0, double 23.3 809 %bo = fmul double %sel, 5.1 810 ret double %bo 811} 812 813define double @sel_constants_fdiv_constant(i1 %cond) { 814; ISEL-LABEL: sel_constants_fdiv_constant: 815; ISEL: # %bb.0: 816; ISEL-NEXT: andi. 3, 3, 1 817; ISEL-NEXT: addis 4, 2, .LCPI46_0@toc@ha 818; ISEL-NEXT: addis 3, 2, .LCPI46_1@toc@ha 819; ISEL-NEXT: addi 4, 4, .LCPI46_0@toc@l 820; ISEL-NEXT: addi 3, 3, .LCPI46_1@toc@l 821; ISEL-NEXT: iselgt 3, 3, 4 822; ISEL-NEXT: lfdx 1, 0, 3 823; ISEL-NEXT: blr 824; 825; NO_ISEL-LABEL: sel_constants_fdiv_constant: 826; NO_ISEL: # %bb.0: 827; NO_ISEL-NEXT: andi. 3, 3, 1 828; NO_ISEL-NEXT: addis 4, 2, .LCPI46_0@toc@ha 829; NO_ISEL-NEXT: addis 3, 2, .LCPI46_1@toc@ha 830; NO_ISEL-NEXT: addi 4, 4, .LCPI46_0@toc@l 831; NO_ISEL-NEXT: addi 3, 3, .LCPI46_1@toc@l 832; NO_ISEL-NEXT: bc 12, 1, .LBB46_2 833; NO_ISEL-NEXT: # %bb.1: 834; NO_ISEL-NEXT: ori 3, 4, 0 835; NO_ISEL-NEXT: b .LBB46_2 836; NO_ISEL-NEXT: .LBB46_2: 837; NO_ISEL-NEXT: lfdx 1, 0, 3 838; NO_ISEL-NEXT: blr 839 %sel = select i1 %cond, double -4.0, double 23.3 840 %bo = fdiv double %sel, 5.1 841 ret double %bo 842} 843 844define double @fdiv_constant_sel_constants(i1 %cond) { 845; ISEL-LABEL: fdiv_constant_sel_constants: 846; ISEL: # %bb.0: 847; ISEL-NEXT: andi. 3, 3, 1 848; ISEL-NEXT: addis 4, 2, .LCPI47_0@toc@ha 849; ISEL-NEXT: addis 3, 2, .LCPI47_1@toc@ha 850; ISEL-NEXT: addi 4, 4, .LCPI47_0@toc@l 851; ISEL-NEXT: addi 3, 3, .LCPI47_1@toc@l 852; ISEL-NEXT: iselgt 3, 3, 4 853; ISEL-NEXT: lfdx 1, 0, 3 854; ISEL-NEXT: blr 855; 856; NO_ISEL-LABEL: fdiv_constant_sel_constants: 857; NO_ISEL: # %bb.0: 858; NO_ISEL-NEXT: andi. 3, 3, 1 859; NO_ISEL-NEXT: addis 4, 2, .LCPI47_0@toc@ha 860; NO_ISEL-NEXT: addis 3, 2, .LCPI47_1@toc@ha 861; NO_ISEL-NEXT: addi 4, 4, .LCPI47_0@toc@l 862; NO_ISEL-NEXT: addi 3, 3, .LCPI47_1@toc@l 863; NO_ISEL-NEXT: bc 12, 1, .LBB47_2 864; NO_ISEL-NEXT: # %bb.1: 865; NO_ISEL-NEXT: ori 3, 4, 0 866; NO_ISEL-NEXT: b .LBB47_2 867; NO_ISEL-NEXT: .LBB47_2: 868; NO_ISEL-NEXT: lfdx 1, 0, 3 869; NO_ISEL-NEXT: blr 870 %sel = select i1 %cond, double -4.0, double 23.3 871 %bo = fdiv double 5.1, %sel 872 ret double %bo 873} 874 875define double @sel_constants_frem_constant(i1 %cond) { 876; ALL-LABEL: sel_constants_frem_constant: 877; ALL: # %bb.0: 878; ALL-NEXT: andi. 3, 3, 1 879; ALL-NEXT: bc 12, 1, .LBB48_2 880; ALL-NEXT: # %bb.1: 881; ALL-NEXT: addis 3, 2, .LCPI48_0@toc@ha 882; ALL-NEXT: lfd 1, .LCPI48_0@toc@l(3) 883; ALL-NEXT: blr 884; ALL-NEXT: .LBB48_2: 885; ALL-NEXT: addis 3, 2, .LCPI48_1@toc@ha 886; ALL-NEXT: lfs 1, .LCPI48_1@toc@l(3) 887; ALL-NEXT: blr 888 %sel = select i1 %cond, double -4.0, double 23.3 889 %bo = frem double %sel, 5.1 890 ret double %bo 891} 892 893define double @frem_constant_sel_constants(i1 %cond) { 894; ISEL-LABEL: frem_constant_sel_constants: 895; ISEL: # %bb.0: 896; ISEL-NEXT: andi. 3, 3, 1 897; ISEL-NEXT: addis 4, 2, .LCPI49_0@toc@ha 898; ISEL-NEXT: addis 3, 2, .LCPI49_1@toc@ha 899; ISEL-NEXT: addi 4, 4, .LCPI49_0@toc@l 900; ISEL-NEXT: addi 3, 3, .LCPI49_1@toc@l 901; ISEL-NEXT: iselgt 3, 3, 4 902; ISEL-NEXT: lfdx 1, 0, 3 903; ISEL-NEXT: blr 904; 905; NO_ISEL-LABEL: frem_constant_sel_constants: 906; NO_ISEL: # %bb.0: 907; NO_ISEL-NEXT: andi. 3, 3, 1 908; NO_ISEL-NEXT: addis 4, 2, .LCPI49_0@toc@ha 909; NO_ISEL-NEXT: addis 3, 2, .LCPI49_1@toc@ha 910; NO_ISEL-NEXT: addi 4, 4, .LCPI49_0@toc@l 911; NO_ISEL-NEXT: addi 3, 3, .LCPI49_1@toc@l 912; NO_ISEL-NEXT: bc 12, 1, .LBB49_2 913; NO_ISEL-NEXT: # %bb.1: 914; NO_ISEL-NEXT: ori 3, 4, 0 915; NO_ISEL-NEXT: b .LBB49_2 916; NO_ISEL-NEXT: .LBB49_2: 917; NO_ISEL-NEXT: lfdx 1, 0, 3 918; NO_ISEL-NEXT: blr 919 %sel = select i1 %cond, double -4.0, double 23.3 920 %bo = frem double 5.1, %sel 921 ret double %bo 922} 923