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: subfic 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: subfic 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; ALL-LABEL: shl_constant_sel_constants: 614; ALL: # %bb.0: 615; ALL-NEXT: clrlwi 3, 3, 31 616; ALL-NEXT: li 4, 1 617; ALL-NEXT: subfic 3, 3, 3 618; ALL-NEXT: slw 3, 4, 3 619; ALL-NEXT: blr 620 %sel = select i1 %cond, i8 2, i8 3 621 %bo = shl i8 1, %sel 622 ret i8 %bo 623} 624 625define i8 @sel_constants_lshr_constant(i1 %cond) { 626; ISEL-LABEL: sel_constants_lshr_constant: 627; ISEL: # %bb.0: 628; ISEL-NEXT: andi. 3, 3, 1 629; ISEL-NEXT: li 4, 7 630; ISEL-NEXT: li 3, 0 631; ISEL-NEXT: iselgt 3, 4, 3 632; ISEL-NEXT: blr 633; 634; NO_ISEL-LABEL: sel_constants_lshr_constant: 635; NO_ISEL: # %bb.0: 636; NO_ISEL-NEXT: andi. 3, 3, 1 637; NO_ISEL-NEXT: li 4, 7 638; NO_ISEL-NEXT: li 3, 0 639; NO_ISEL-NEXT: bc 12, 1, .LBB38_1 640; NO_ISEL-NEXT: blr 641; NO_ISEL-NEXT: .LBB38_1: 642; NO_ISEL-NEXT: addi 3, 4, 0 643; NO_ISEL-NEXT: blr 644 %sel = select i1 %cond, i8 -4, i8 23 645 %bo = lshr i8 %sel, 5 646 ret i8 %bo 647} 648 649define i8 @lshr_constant_sel_constants(i1 %cond) { 650; ALL-LABEL: lshr_constant_sel_constants: 651; ALL: # %bb.0: 652; ALL-NEXT: clrlwi 3, 3, 31 653; ALL-NEXT: li 4, 64 654; ALL-NEXT: subfic 3, 3, 3 655; ALL-NEXT: srw 3, 4, 3 656; ALL-NEXT: blr 657 %sel = select i1 %cond, i8 2, i8 3 658 %bo = lshr i8 64, %sel 659 ret i8 %bo 660} 661 662 663define i8 @sel_constants_ashr_constant(i1 %cond) { 664; ALL-LABEL: sel_constants_ashr_constant: 665; ALL: # %bb.0: 666; ALL-NEXT: clrldi 3, 3, 63 667; ALL-NEXT: neg 3, 3 668; ALL-NEXT: blr 669 %sel = select i1 %cond, i8 -4, i8 23 670 %bo = ashr i8 %sel, 5 671 ret i8 %bo 672} 673 674define i8 @ashr_constant_sel_constants(i1 %cond) { 675; ALL-LABEL: ashr_constant_sel_constants: 676; ALL: # %bb.0: 677; ALL-NEXT: clrlwi 3, 3, 31 678; ALL-NEXT: li 4, -128 679; ALL-NEXT: subfic 3, 3, 3 680; ALL-NEXT: sraw 3, 4, 3 681; ALL-NEXT: blr 682 %sel = select i1 %cond, i8 2, i8 3 683 %bo = ashr i8 128, %sel 684 ret i8 %bo 685} 686 687define double @sel_constants_fadd_constant(i1 %cond) { 688; ISEL-LABEL: sel_constants_fadd_constant: 689; ISEL: # %bb.0: 690; ISEL-NEXT: andi. 3, 3, 1 691; ISEL-NEXT: addis 4, 2, .LCPI42_0@toc@ha 692; ISEL-NEXT: addis 3, 2, .LCPI42_1@toc@ha 693; ISEL-NEXT: addi 4, 4, .LCPI42_0@toc@l 694; ISEL-NEXT: addi 3, 3, .LCPI42_1@toc@l 695; ISEL-NEXT: iselgt 3, 3, 4 696; ISEL-NEXT: lfdx 1, 0, 3 697; ISEL-NEXT: blr 698; 699; NO_ISEL-LABEL: sel_constants_fadd_constant: 700; NO_ISEL: # %bb.0: 701; NO_ISEL-NEXT: andi. 3, 3, 1 702; NO_ISEL-NEXT: addis 4, 2, .LCPI42_0@toc@ha 703; NO_ISEL-NEXT: addis 3, 2, .LCPI42_1@toc@ha 704; NO_ISEL-NEXT: addi 4, 4, .LCPI42_0@toc@l 705; NO_ISEL-NEXT: addi 3, 3, .LCPI42_1@toc@l 706; NO_ISEL-NEXT: bc 12, 1, .LBB42_2 707; NO_ISEL-NEXT: # %bb.1: 708; NO_ISEL-NEXT: ori 3, 4, 0 709; NO_ISEL-NEXT: b .LBB42_2 710; NO_ISEL-NEXT: .LBB42_2: 711; NO_ISEL-NEXT: lfdx 1, 0, 3 712; NO_ISEL-NEXT: blr 713 %sel = select i1 %cond, double -4.0, double 23.3 714 %bo = fadd double %sel, 5.1 715 ret double %bo 716} 717 718define double @sel_constants_fsub_constant(i1 %cond) { 719; ISEL-LABEL: sel_constants_fsub_constant: 720; ISEL: # %bb.0: 721; ISEL-NEXT: andi. 3, 3, 1 722; ISEL-NEXT: addis 4, 2, .LCPI43_0@toc@ha 723; ISEL-NEXT: addis 3, 2, .LCPI43_1@toc@ha 724; ISEL-NEXT: addi 4, 4, .LCPI43_0@toc@l 725; ISEL-NEXT: addi 3, 3, .LCPI43_1@toc@l 726; ISEL-NEXT: iselgt 3, 3, 4 727; ISEL-NEXT: lfdx 1, 0, 3 728; ISEL-NEXT: blr 729; 730; NO_ISEL-LABEL: sel_constants_fsub_constant: 731; NO_ISEL: # %bb.0: 732; NO_ISEL-NEXT: andi. 3, 3, 1 733; NO_ISEL-NEXT: addis 4, 2, .LCPI43_0@toc@ha 734; NO_ISEL-NEXT: addis 3, 2, .LCPI43_1@toc@ha 735; NO_ISEL-NEXT: addi 4, 4, .LCPI43_0@toc@l 736; NO_ISEL-NEXT: addi 3, 3, .LCPI43_1@toc@l 737; NO_ISEL-NEXT: bc 12, 1, .LBB43_2 738; NO_ISEL-NEXT: # %bb.1: 739; NO_ISEL-NEXT: ori 3, 4, 0 740; NO_ISEL-NEXT: b .LBB43_2 741; NO_ISEL-NEXT: .LBB43_2: 742; NO_ISEL-NEXT: lfdx 1, 0, 3 743; NO_ISEL-NEXT: blr 744 %sel = select i1 %cond, double -4.0, double 23.3 745 %bo = fsub double %sel, 5.1 746 ret double %bo 747} 748 749define double @fsub_constant_sel_constants(i1 %cond) { 750; ISEL-LABEL: fsub_constant_sel_constants: 751; ISEL: # %bb.0: 752; ISEL-NEXT: andi. 3, 3, 1 753; ISEL-NEXT: addis 4, 2, .LCPI44_0@toc@ha 754; ISEL-NEXT: addis 3, 2, .LCPI44_1@toc@ha 755; ISEL-NEXT: addi 4, 4, .LCPI44_0@toc@l 756; ISEL-NEXT: addi 3, 3, .LCPI44_1@toc@l 757; ISEL-NEXT: iselgt 3, 3, 4 758; ISEL-NEXT: lfdx 1, 0, 3 759; ISEL-NEXT: blr 760; 761; NO_ISEL-LABEL: fsub_constant_sel_constants: 762; NO_ISEL: # %bb.0: 763; NO_ISEL-NEXT: andi. 3, 3, 1 764; NO_ISEL-NEXT: addis 4, 2, .LCPI44_0@toc@ha 765; NO_ISEL-NEXT: addis 3, 2, .LCPI44_1@toc@ha 766; NO_ISEL-NEXT: addi 4, 4, .LCPI44_0@toc@l 767; NO_ISEL-NEXT: addi 3, 3, .LCPI44_1@toc@l 768; NO_ISEL-NEXT: bc 12, 1, .LBB44_2 769; NO_ISEL-NEXT: # %bb.1: 770; NO_ISEL-NEXT: ori 3, 4, 0 771; NO_ISEL-NEXT: b .LBB44_2 772; NO_ISEL-NEXT: .LBB44_2: 773; NO_ISEL-NEXT: lfdx 1, 0, 3 774; NO_ISEL-NEXT: blr 775 %sel = select i1 %cond, double -4.0, double 23.3 776 %bo = fsub double 5.1, %sel 777 ret double %bo 778} 779 780define double @sel_constants_fmul_constant(i1 %cond) { 781; ISEL-LABEL: sel_constants_fmul_constant: 782; ISEL: # %bb.0: 783; ISEL-NEXT: andi. 3, 3, 1 784; ISEL-NEXT: addis 4, 2, .LCPI45_0@toc@ha 785; ISEL-NEXT: addis 3, 2, .LCPI45_1@toc@ha 786; ISEL-NEXT: addi 4, 4, .LCPI45_0@toc@l 787; ISEL-NEXT: addi 3, 3, .LCPI45_1@toc@l 788; ISEL-NEXT: iselgt 3, 3, 4 789; ISEL-NEXT: lfdx 1, 0, 3 790; ISEL-NEXT: blr 791; 792; NO_ISEL-LABEL: sel_constants_fmul_constant: 793; NO_ISEL: # %bb.0: 794; NO_ISEL-NEXT: andi. 3, 3, 1 795; NO_ISEL-NEXT: addis 4, 2, .LCPI45_0@toc@ha 796; NO_ISEL-NEXT: addis 3, 2, .LCPI45_1@toc@ha 797; NO_ISEL-NEXT: addi 4, 4, .LCPI45_0@toc@l 798; NO_ISEL-NEXT: addi 3, 3, .LCPI45_1@toc@l 799; NO_ISEL-NEXT: bc 12, 1, .LBB45_2 800; NO_ISEL-NEXT: # %bb.1: 801; NO_ISEL-NEXT: ori 3, 4, 0 802; NO_ISEL-NEXT: b .LBB45_2 803; NO_ISEL-NEXT: .LBB45_2: 804; NO_ISEL-NEXT: lfdx 1, 0, 3 805; NO_ISEL-NEXT: blr 806 %sel = select i1 %cond, double -4.0, double 23.3 807 %bo = fmul double %sel, 5.1 808 ret double %bo 809} 810 811define double @sel_constants_fdiv_constant(i1 %cond) { 812; ISEL-LABEL: sel_constants_fdiv_constant: 813; ISEL: # %bb.0: 814; ISEL-NEXT: andi. 3, 3, 1 815; ISEL-NEXT: addis 4, 2, .LCPI46_0@toc@ha 816; ISEL-NEXT: addis 3, 2, .LCPI46_1@toc@ha 817; ISEL-NEXT: addi 4, 4, .LCPI46_0@toc@l 818; ISEL-NEXT: addi 3, 3, .LCPI46_1@toc@l 819; ISEL-NEXT: iselgt 3, 3, 4 820; ISEL-NEXT: lfdx 1, 0, 3 821; ISEL-NEXT: blr 822; 823; NO_ISEL-LABEL: sel_constants_fdiv_constant: 824; NO_ISEL: # %bb.0: 825; NO_ISEL-NEXT: andi. 3, 3, 1 826; NO_ISEL-NEXT: addis 4, 2, .LCPI46_0@toc@ha 827; NO_ISEL-NEXT: addis 3, 2, .LCPI46_1@toc@ha 828; NO_ISEL-NEXT: addi 4, 4, .LCPI46_0@toc@l 829; NO_ISEL-NEXT: addi 3, 3, .LCPI46_1@toc@l 830; NO_ISEL-NEXT: bc 12, 1, .LBB46_2 831; NO_ISEL-NEXT: # %bb.1: 832; NO_ISEL-NEXT: ori 3, 4, 0 833; NO_ISEL-NEXT: b .LBB46_2 834; NO_ISEL-NEXT: .LBB46_2: 835; NO_ISEL-NEXT: lfdx 1, 0, 3 836; NO_ISEL-NEXT: blr 837 %sel = select i1 %cond, double -4.0, double 23.3 838 %bo = fdiv double %sel, 5.1 839 ret double %bo 840} 841 842define double @fdiv_constant_sel_constants(i1 %cond) { 843; ISEL-LABEL: fdiv_constant_sel_constants: 844; ISEL: # %bb.0: 845; ISEL-NEXT: andi. 3, 3, 1 846; ISEL-NEXT: addis 4, 2, .LCPI47_0@toc@ha 847; ISEL-NEXT: addis 3, 2, .LCPI47_1@toc@ha 848; ISEL-NEXT: addi 4, 4, .LCPI47_0@toc@l 849; ISEL-NEXT: addi 3, 3, .LCPI47_1@toc@l 850; ISEL-NEXT: iselgt 3, 3, 4 851; ISEL-NEXT: lfdx 1, 0, 3 852; ISEL-NEXT: blr 853; 854; NO_ISEL-LABEL: fdiv_constant_sel_constants: 855; NO_ISEL: # %bb.0: 856; NO_ISEL-NEXT: andi. 3, 3, 1 857; NO_ISEL-NEXT: addis 4, 2, .LCPI47_0@toc@ha 858; NO_ISEL-NEXT: addis 3, 2, .LCPI47_1@toc@ha 859; NO_ISEL-NEXT: addi 4, 4, .LCPI47_0@toc@l 860; NO_ISEL-NEXT: addi 3, 3, .LCPI47_1@toc@l 861; NO_ISEL-NEXT: bc 12, 1, .LBB47_2 862; NO_ISEL-NEXT: # %bb.1: 863; NO_ISEL-NEXT: ori 3, 4, 0 864; NO_ISEL-NEXT: b .LBB47_2 865; NO_ISEL-NEXT: .LBB47_2: 866; NO_ISEL-NEXT: lfdx 1, 0, 3 867; NO_ISEL-NEXT: blr 868 %sel = select i1 %cond, double -4.0, double 23.3 869 %bo = fdiv double 5.1, %sel 870 ret double %bo 871} 872 873define double @sel_constants_frem_constant(i1 %cond) { 874; ALL-LABEL: sel_constants_frem_constant: 875; ALL: # %bb.0: 876; ALL-NEXT: andi. 3, 3, 1 877; ALL-NEXT: bc 12, 1, .LBB48_2 878; ALL-NEXT: # %bb.1: 879; ALL-NEXT: addis 3, 2, .LCPI48_0@toc@ha 880; ALL-NEXT: lfd 1, .LCPI48_0@toc@l(3) 881; ALL-NEXT: blr 882; ALL-NEXT: .LBB48_2: 883; ALL-NEXT: addis 3, 2, .LCPI48_1@toc@ha 884; ALL-NEXT: lfs 1, .LCPI48_1@toc@l(3) 885; ALL-NEXT: blr 886 %sel = select i1 %cond, double -4.0, double 23.3 887 %bo = frem double %sel, 5.1 888 ret double %bo 889} 890 891define double @frem_constant_sel_constants(i1 %cond) { 892; ISEL-LABEL: frem_constant_sel_constants: 893; ISEL: # %bb.0: 894; ISEL-NEXT: andi. 3, 3, 1 895; ISEL-NEXT: addis 4, 2, .LCPI49_0@toc@ha 896; ISEL-NEXT: addis 3, 2, .LCPI49_1@toc@ha 897; ISEL-NEXT: addi 4, 4, .LCPI49_0@toc@l 898; ISEL-NEXT: addi 3, 3, .LCPI49_1@toc@l 899; ISEL-NEXT: iselgt 3, 3, 4 900; ISEL-NEXT: lfdx 1, 0, 3 901; ISEL-NEXT: blr 902; 903; NO_ISEL-LABEL: frem_constant_sel_constants: 904; NO_ISEL: # %bb.0: 905; NO_ISEL-NEXT: andi. 3, 3, 1 906; NO_ISEL-NEXT: addis 4, 2, .LCPI49_0@toc@ha 907; NO_ISEL-NEXT: addis 3, 2, .LCPI49_1@toc@ha 908; NO_ISEL-NEXT: addi 4, 4, .LCPI49_0@toc@l 909; NO_ISEL-NEXT: addi 3, 3, .LCPI49_1@toc@l 910; NO_ISEL-NEXT: bc 12, 1, .LBB49_2 911; NO_ISEL-NEXT: # %bb.1: 912; NO_ISEL-NEXT: ori 3, 4, 0 913; NO_ISEL-NEXT: b .LBB49_2 914; NO_ISEL-NEXT: .LBB49_2: 915; NO_ISEL-NEXT: lfdx 1, 0, 3 916; NO_ISEL-NEXT: blr 917 %sel = select i1 %cond, double -4.0, double 23.3 918 %bo = frem double 5.1, %sel 919 ret double %bo 920} 921