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