888 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=powerpc64le-unknown-unknown -verify-machineinstrs -mattr=+isel | FileCheck %s --check-prefix=ALL --check-prefix=ISEL3; RUN: llc < %s -mtriple=powerpc64le-unknown-unknown -verify-machineinstrs -mattr=-isel | FileCheck %s --check-prefix=ALL --check-prefix=NO_ISEL4 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, 314; ALL-NEXT: clrldi 3, 3, 6315; ALL-NEXT: blr16 %sel = select i1 %cond, i32 0, i32 117 ret i32 %sel18}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, 124; ALL-NEXT: blr25 %sel = select i1 %cond, i32 0, i32 126 ret i32 %sel27}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, 333; ALL-NEXT: clrldi 3, 3, 6334; ALL-NEXT: blr35 %sel = select i1 %cond, i32 0, i32 136 ret i32 %sel37}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, 6345; ALL-NEXT: blr46 %sel = select i1 %cond, i32 1, i32 047 ret i32 %sel48}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: blr54 %sel = select i1 %cond, i32 1, i32 055 ret i32 %sel56}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, 6362; ALL-NEXT: blr63 %sel = select i1 %cond, i32 1, i32 064 ret i32 %sel65}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, 6373; ALL-NEXT: addi 3, 3, -174; ALL-NEXT: blr75 %sel = select i1 %cond, i32 0, i32 -176 ret i32 %sel77}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, -183; ALL-NEXT: blr84 %sel = select i1 %cond, i32 0, i32 -185 ret i32 %sel86}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, 392; ALL-NEXT: blr93 %sel = select i1 %cond, i32 0, i32 -194 ret i32 %sel95}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, 63103; ALL-NEXT: neg 3, 3104; ALL-NEXT: blr105 %sel = select i1 %cond, i32 -1, i32 0106 ret i32 %sel107}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, 3113; ALL-NEXT: blr114 %sel = select i1 %cond, i32 -1, i32 0115 ret i32 %sel116}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: blr122 %sel = select i1 %cond, i32 -1, i32 0123 ret i32 %sel124}125 126; select Cond, C+1, C --> add (zext Cond), C127 128define i32 @select_Cplus1_C(i1 %cond) {129; ALL-LABEL: select_Cplus1_C:130; ALL: # %bb.0:131; ALL-NEXT: clrldi 3, 3, 63132; ALL-NEXT: addi 3, 3, 41133; ALL-NEXT: blr134 %sel = select i1 %cond, i32 42, i32 41135 ret i32 %sel136}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, 41142; ALL-NEXT: blr143 %sel = select i1 %cond, i32 42, i32 41144 ret i32 %sel145}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, 41151; ALL-NEXT: blr152 %sel = select i1 %cond, i32 42, i32 41153 ret i32 %sel154}155 156; select Cond, C, C+1 --> add (sext Cond), C157 158define i32 @select_C_Cplus1(i1 %cond) {159; ALL-LABEL: select_C_Cplus1:160; ALL: # %bb.0:161; ALL-NEXT: clrldi 3, 3, 63162; ALL-NEXT: subfic 3, 3, 42163; ALL-NEXT: blr164 %sel = select i1 %cond, i32 41, i32 42165 ret i32 %sel166}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, 42172; ALL-NEXT: blr173 %sel = select i1 %cond, i32 41, i32 42174 ret i32 %sel175}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, 42181; ALL-NEXT: blr182 %sel = select i1 %cond, i32 41, i32 42183 ret i32 %sel184}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), C2188 189define i32 @select_C1_C2(i1 %cond) {190; ISEL-LABEL: select_C1_C2:191; ISEL: # %bb.0:192; ISEL-NEXT: andi. 3, 3, 1193; ISEL-NEXT: li 3, 42194; ISEL-NEXT: li 4, 421195; ISEL-NEXT: iselgt 3, 4, 3196; ISEL-NEXT: blr197;198; NO_ISEL-LABEL: select_C1_C2:199; NO_ISEL: # %bb.0:200; NO_ISEL-NEXT: andi. 3, 3, 1201; NO_ISEL-NEXT: li 3, 421202; NO_ISEL-NEXT: bclr 12, 1, 0203; NO_ISEL-NEXT: # %bb.1:204; NO_ISEL-NEXT: li 3, 42205; NO_ISEL-NEXT: blr206 %sel = select i1 %cond, i32 421, i32 42207 ret i32 %sel208}209 210define i32 @select_C1_C2_zeroext(i1 zeroext %cond) {211; ISEL-LABEL: select_C1_C2_zeroext:212; ISEL: # %bb.0:213; ISEL-NEXT: andi. 3, 3, 1214; ISEL-NEXT: li 3, 42215; ISEL-NEXT: li 4, 421216; ISEL-NEXT: iselgt 3, 4, 3217; ISEL-NEXT: blr218;219; NO_ISEL-LABEL: select_C1_C2_zeroext:220; NO_ISEL: # %bb.0:221; NO_ISEL-NEXT: andi. 3, 3, 1222; NO_ISEL-NEXT: li 3, 421223; NO_ISEL-NEXT: bclr 12, 1, 0224; NO_ISEL-NEXT: # %bb.1:225; NO_ISEL-NEXT: li 3, 42226; NO_ISEL-NEXT: blr227 %sel = select i1 %cond, i32 421, i32 42228 ret i32 %sel229}230 231define i32 @select_C1_C2_signext(i1 signext %cond) {232; ISEL-LABEL: select_C1_C2_signext:233; ISEL: # %bb.0:234; ISEL-NEXT: andi. 3, 3, 1235; ISEL-NEXT: li 3, 42236; ISEL-NEXT: li 4, 421237; ISEL-NEXT: iselgt 3, 4, 3238; ISEL-NEXT: blr239;240; NO_ISEL-LABEL: select_C1_C2_signext:241; NO_ISEL: # %bb.0:242; NO_ISEL-NEXT: andi. 3, 3, 1243; NO_ISEL-NEXT: li 3, 421244; NO_ISEL-NEXT: bclr 12, 1, 0245; NO_ISEL-NEXT: # %bb.1:246; NO_ISEL-NEXT: li 3, 42247; NO_ISEL-NEXT: blr248 %sel = select i1 %cond, i32 421, i32 42249 ret i32 %sel250}251 252; A binary operator with constant after the select should always get folded into the select.253 254define i8 @sel_constants_add_constant(i1 %cond) {255; ISEL-LABEL: sel_constants_add_constant:256; ISEL: # %bb.0:257; ISEL-NEXT: andi. 3, 3, 1258; ISEL-NEXT: li 3, 28259; ISEL-NEXT: li 4, 1260; ISEL-NEXT: iselgt 3, 4, 3261; ISEL-NEXT: blr262;263; NO_ISEL-LABEL: sel_constants_add_constant:264; NO_ISEL: # %bb.0:265; NO_ISEL-NEXT: andi. 3, 3, 1266; NO_ISEL-NEXT: li 3, 1267; NO_ISEL-NEXT: bclr 12, 1, 0268; NO_ISEL-NEXT: # %bb.1:269; NO_ISEL-NEXT: li 3, 28270; NO_ISEL-NEXT: blr271 %sel = select i1 %cond, i8 -4, i8 23272 %bo = add i8 %sel, 5273 ret i8 %bo274}275 276define i8 @sel_constants_sub_constant(i1 %cond) {277; ISEL-LABEL: sel_constants_sub_constant:278; ISEL: # %bb.0:279; ISEL-NEXT: andi. 3, 3, 1280; ISEL-NEXT: li 3, 18281; ISEL-NEXT: li 4, -9282; ISEL-NEXT: iselgt 3, 4, 3283; ISEL-NEXT: blr284;285; NO_ISEL-LABEL: sel_constants_sub_constant:286; NO_ISEL: # %bb.0:287; NO_ISEL-NEXT: andi. 3, 3, 1288; NO_ISEL-NEXT: li 3, -9289; NO_ISEL-NEXT: bclr 12, 1, 0290; NO_ISEL-NEXT: # %bb.1:291; NO_ISEL-NEXT: li 3, 18292; NO_ISEL-NEXT: blr293 %sel = select i1 %cond, i8 -4, i8 23294 %bo = sub i8 %sel, 5295 ret i8 %bo296}297 298define i8 @sel_constants_sub_constant_sel_constants(i1 %cond) {299; ISEL-LABEL: sel_constants_sub_constant_sel_constants:300; ISEL: # %bb.0:301; ISEL-NEXT: andi. 3, 3, 1302; ISEL-NEXT: li 3, 2303; ISEL-NEXT: li 4, 9304; ISEL-NEXT: iselgt 3, 4, 3305; ISEL-NEXT: blr306;307; NO_ISEL-LABEL: sel_constants_sub_constant_sel_constants:308; NO_ISEL: # %bb.0:309; NO_ISEL-NEXT: andi. 3, 3, 1310; NO_ISEL-NEXT: li 3, 9311; NO_ISEL-NEXT: bclr 12, 1, 0312; NO_ISEL-NEXT: # %bb.1:313; NO_ISEL-NEXT: li 3, 2314; NO_ISEL-NEXT: blr315 %sel = select i1 %cond, i8 -4, i8 3316 %bo = sub i8 5, %sel317 ret i8 %bo318}319 320define i8 @sel_constants_mul_constant(i1 %cond) {321; ISEL-LABEL: sel_constants_mul_constant:322; ISEL: # %bb.0:323; ISEL-NEXT: andi. 3, 3, 1324; ISEL-NEXT: li 3, 115325; ISEL-NEXT: li 4, -20326; ISEL-NEXT: iselgt 3, 4, 3327; ISEL-NEXT: blr328;329; NO_ISEL-LABEL: sel_constants_mul_constant:330; NO_ISEL: # %bb.0:331; NO_ISEL-NEXT: andi. 3, 3, 1332; NO_ISEL-NEXT: li 3, -20333; NO_ISEL-NEXT: bclr 12, 1, 0334; NO_ISEL-NEXT: # %bb.1:335; NO_ISEL-NEXT: li 3, 115336; NO_ISEL-NEXT: blr337 %sel = select i1 %cond, i8 -4, i8 23338 %bo = mul i8 %sel, 5339 ret i8 %bo340}341 342define i8 @sel_constants_sdiv_constant(i1 %cond) {343; ISEL-LABEL: sel_constants_sdiv_constant:344; ISEL: # %bb.0:345; ISEL-NEXT: andi. 3, 3, 1346; ISEL-NEXT: li 3, 4347; ISEL-NEXT: iselgt 3, 0, 3348; ISEL-NEXT: blr349;350; NO_ISEL-LABEL: sel_constants_sdiv_constant:351; NO_ISEL: # %bb.0:352; NO_ISEL-NEXT: andi. 3, 3, 1353; NO_ISEL-NEXT: li 3, 0354; NO_ISEL-NEXT: bclr 12, 1, 0355; NO_ISEL-NEXT: # %bb.1:356; NO_ISEL-NEXT: li 3, 4357; NO_ISEL-NEXT: blr358 %sel = select i1 %cond, i8 -4, i8 23359 %bo = sdiv i8 %sel, 5360 ret i8 %bo361}362 363define i8 @sdiv_constant_sel_constants(i1 %cond) {364; ISEL-LABEL: sdiv_constant_sel_constants:365; ISEL: # %bb.0:366; ISEL-NEXT: andi. 3, 3, 1367; ISEL-NEXT: li 3, 5368; ISEL-NEXT: iselgt 3, 0, 3369; ISEL-NEXT: blr370;371; NO_ISEL-LABEL: sdiv_constant_sel_constants:372; NO_ISEL: # %bb.0:373; NO_ISEL-NEXT: andi. 3, 3, 1374; NO_ISEL-NEXT: li 3, 0375; NO_ISEL-NEXT: bclr 12, 1, 0376; NO_ISEL-NEXT: # %bb.1:377; NO_ISEL-NEXT: li 3, 5378; NO_ISEL-NEXT: blr379 %sel = select i1 %cond, i8 121, i8 23380 %bo = sdiv i8 120, %sel381 ret i8 %bo382}383 384define i8 @sel_constants_udiv_constant(i1 %cond) {385; ISEL-LABEL: sel_constants_udiv_constant:386; ISEL: # %bb.0:387; ISEL-NEXT: andi. 3, 3, 1388; ISEL-NEXT: li 3, 4389; ISEL-NEXT: li 4, 50390; ISEL-NEXT: iselgt 3, 4, 3391; ISEL-NEXT: blr392;393; NO_ISEL-LABEL: sel_constants_udiv_constant:394; NO_ISEL: # %bb.0:395; NO_ISEL-NEXT: andi. 3, 3, 1396; NO_ISEL-NEXT: li 3, 50397; NO_ISEL-NEXT: bclr 12, 1, 0398; NO_ISEL-NEXT: # %bb.1:399; NO_ISEL-NEXT: li 3, 4400; NO_ISEL-NEXT: blr401 %sel = select i1 %cond, i8 -4, i8 23402 %bo = udiv i8 %sel, 5403 ret i8 %bo404}405 406define i8 @udiv_constant_sel_constants(i1 %cond) {407; ISEL-LABEL: udiv_constant_sel_constants:408; ISEL: # %bb.0:409; ISEL-NEXT: andi. 3, 3, 1410; ISEL-NEXT: li 3, 5411; ISEL-NEXT: iselgt 3, 0, 3412; ISEL-NEXT: blr413;414; NO_ISEL-LABEL: udiv_constant_sel_constants:415; NO_ISEL: # %bb.0:416; NO_ISEL-NEXT: andi. 3, 3, 1417; NO_ISEL-NEXT: li 3, 0418; NO_ISEL-NEXT: bclr 12, 1, 0419; NO_ISEL-NEXT: # %bb.1:420; NO_ISEL-NEXT: li 3, 5421; NO_ISEL-NEXT: blr422 %sel = select i1 %cond, i8 -4, i8 23423 %bo = udiv i8 120, %sel424 ret i8 %bo425}426 427define i8 @sel_constants_srem_constant(i1 %cond) {428; ISEL-LABEL: sel_constants_srem_constant:429; ISEL: # %bb.0:430; ISEL-NEXT: andi. 3, 3, 1431; ISEL-NEXT: li 3, 3432; ISEL-NEXT: li 4, -4433; ISEL-NEXT: iselgt 3, 4, 3434; ISEL-NEXT: blr435;436; NO_ISEL-LABEL: sel_constants_srem_constant:437; NO_ISEL: # %bb.0:438; NO_ISEL-NEXT: andi. 3, 3, 1439; NO_ISEL-NEXT: li 3, -4440; NO_ISEL-NEXT: bclr 12, 1, 0441; NO_ISEL-NEXT: # %bb.1:442; NO_ISEL-NEXT: li 3, 3443; NO_ISEL-NEXT: blr444 %sel = select i1 %cond, i8 -4, i8 23445 %bo = srem i8 %sel, 5446 ret i8 %bo447}448 449define i8 @srem_constant_sel_constants(i1 %cond) {450; ISEL-LABEL: srem_constant_sel_constants:451; ISEL: # %bb.0:452; ISEL-NEXT: andi. 3, 3, 1453; ISEL-NEXT: li 3, 5454; ISEL-NEXT: li 4, 120455; ISEL-NEXT: iselgt 3, 4, 3456; ISEL-NEXT: blr457;458; NO_ISEL-LABEL: srem_constant_sel_constants:459; NO_ISEL: # %bb.0:460; NO_ISEL-NEXT: andi. 3, 3, 1461; NO_ISEL-NEXT: li 3, 120462; NO_ISEL-NEXT: bclr 12, 1, 0463; NO_ISEL-NEXT: # %bb.1:464; NO_ISEL-NEXT: li 3, 5465; NO_ISEL-NEXT: blr466 %sel = select i1 %cond, i8 121, i8 23467 %bo = srem i8 120, %sel468 ret i8 %bo469}470 471define i8 @sel_constants_urem_constant(i1 %cond) {472; ALL-LABEL: sel_constants_urem_constant:473; ALL: # %bb.0:474; ALL-NEXT: clrldi 3, 3, 63475; ALL-NEXT: xori 3, 3, 3476; ALL-NEXT: blr477 %sel = select i1 %cond, i8 -4, i8 23478 %bo = urem i8 %sel, 5479 ret i8 %bo480}481 482define i8 @urem_constant_sel_constants(i1 %cond) {483; ISEL-LABEL: urem_constant_sel_constants:484; ISEL: # %bb.0:485; ISEL-NEXT: andi. 3, 3, 1486; ISEL-NEXT: li 3, 5487; ISEL-NEXT: li 4, 120488; ISEL-NEXT: iselgt 3, 4, 3489; ISEL-NEXT: blr490;491; NO_ISEL-LABEL: urem_constant_sel_constants:492; NO_ISEL: # %bb.0:493; NO_ISEL-NEXT: andi. 3, 3, 1494; NO_ISEL-NEXT: li 3, 120495; NO_ISEL-NEXT: bclr 12, 1, 0496; NO_ISEL-NEXT: # %bb.1:497; NO_ISEL-NEXT: li 3, 5498; NO_ISEL-NEXT: blr499 %sel = select i1 %cond, i8 -4, i8 23500 %bo = urem i8 120, %sel501 ret i8 %bo502}503 504define i8 @sel_constants_and_constant(i1 %cond) {505; ALL-LABEL: sel_constants_and_constant:506; ALL: # %bb.0:507; ALL-NEXT: clrldi 3, 3, 63508; ALL-NEXT: xori 3, 3, 5509; ALL-NEXT: blr510 %sel = select i1 %cond, i8 -4, i8 23511 %bo = and i8 %sel, 5512 ret i8 %bo513}514 515define i8 @sel_constants_or_constant(i1 %cond) {516; ISEL-LABEL: sel_constants_or_constant:517; ISEL: # %bb.0:518; ISEL-NEXT: andi. 3, 3, 1519; ISEL-NEXT: li 3, 23520; ISEL-NEXT: li 4, -3521; ISEL-NEXT: iselgt 3, 4, 3522; ISEL-NEXT: blr523;524; NO_ISEL-LABEL: sel_constants_or_constant:525; NO_ISEL: # %bb.0:526; NO_ISEL-NEXT: andi. 3, 3, 1527; NO_ISEL-NEXT: li 3, -3528; NO_ISEL-NEXT: bclr 12, 1, 0529; NO_ISEL-NEXT: # %bb.1:530; NO_ISEL-NEXT: li 3, 23531; NO_ISEL-NEXT: blr532 %sel = select i1 %cond, i8 -4, i8 23533 %bo = or i8 %sel, 5534 ret i8 %bo535}536 537define i8 @sel_constants_xor_constant(i1 %cond) {538; ISEL-LABEL: sel_constants_xor_constant:539; ISEL: # %bb.0:540; ISEL-NEXT: andi. 3, 3, 1541; ISEL-NEXT: li 3, 18542; ISEL-NEXT: li 4, -7543; ISEL-NEXT: iselgt 3, 4, 3544; ISEL-NEXT: blr545;546; NO_ISEL-LABEL: sel_constants_xor_constant:547; NO_ISEL: # %bb.0:548; NO_ISEL-NEXT: andi. 3, 3, 1549; NO_ISEL-NEXT: li 3, -7550; NO_ISEL-NEXT: bclr 12, 1, 0551; NO_ISEL-NEXT: # %bb.1:552; NO_ISEL-NEXT: li 3, 18553; NO_ISEL-NEXT: blr554 %sel = select i1 %cond, i8 -4, i8 23555 %bo = xor i8 %sel, 5556 ret i8 %bo557}558 559define i8 @sel_constants_shl_constant(i1 %cond) {560; ISEL-LABEL: sel_constants_shl_constant:561; ISEL: # %bb.0:562; ISEL-NEXT: andi. 3, 3, 1563; ISEL-NEXT: li 3, -32564; ISEL-NEXT: li 4, -128565; ISEL-NEXT: iselgt 3, 4, 3566; ISEL-NEXT: blr567;568; NO_ISEL-LABEL: sel_constants_shl_constant:569; NO_ISEL: # %bb.0:570; NO_ISEL-NEXT: andi. 3, 3, 1571; NO_ISEL-NEXT: li 3, -128572; NO_ISEL-NEXT: bclr 12, 1, 0573; NO_ISEL-NEXT: # %bb.1:574; NO_ISEL-NEXT: li 3, -32575; NO_ISEL-NEXT: blr576 %sel = select i1 %cond, i8 -4, i8 23577 %bo = shl i8 %sel, 5578 ret i8 %bo579}580 581define i8 @shl_constant_sel_constants(i1 %cond) {582; ALL-LABEL: shl_constant_sel_constants:583; ALL: # %bb.0:584; ALL-NEXT: clrlwi 3, 3, 31585; ALL-NEXT: li 4, 1586; ALL-NEXT: xori 3, 3, 3587; ALL-NEXT: slw 3, 4, 3588; ALL-NEXT: blr589 %sel = select i1 %cond, i8 2, i8 3590 %bo = shl i8 1, %sel591 ret i8 %bo592}593 594define i8 @sel_constants_lshr_constant(i1 %cond) {595; ISEL-LABEL: sel_constants_lshr_constant:596; ISEL: # %bb.0:597; ISEL-NEXT: andi. 3, 3, 1598; ISEL-NEXT: li 3, 0599; ISEL-NEXT: li 4, 7600; ISEL-NEXT: iselgt 3, 4, 3601; ISEL-NEXT: blr602;603; NO_ISEL-LABEL: sel_constants_lshr_constant:604; NO_ISEL: # %bb.0:605; NO_ISEL-NEXT: andi. 3, 3, 1606; NO_ISEL-NEXT: li 3, 7607; NO_ISEL-NEXT: bclr 12, 1, 0608; NO_ISEL-NEXT: # %bb.1:609; NO_ISEL-NEXT: li 3, 0610; NO_ISEL-NEXT: blr611 %sel = select i1 %cond, i8 -4, i8 23612 %bo = lshr i8 %sel, 5613 ret i8 %bo614}615 616define i8 @lshr_constant_sel_constants(i1 %cond) {617; ALL-LABEL: lshr_constant_sel_constants:618; ALL: # %bb.0:619; ALL-NEXT: clrlwi 3, 3, 31620; ALL-NEXT: li 4, 64621; ALL-NEXT: xori 3, 3, 3622; ALL-NEXT: srw 3, 4, 3623; ALL-NEXT: blr624 %sel = select i1 %cond, i8 2, i8 3625 %bo = lshr i8 64, %sel626 ret i8 %bo627}628 629 630define i8 @sel_constants_ashr_constant(i1 %cond) {631; ALL-LABEL: sel_constants_ashr_constant:632; ALL: # %bb.0:633; ALL-NEXT: clrlwi 3, 3, 31634; ALL-NEXT: neg 3, 3635; ALL-NEXT: blr636 %sel = select i1 %cond, i8 -4, i8 23637 %bo = ashr i8 %sel, 5638 ret i8 %bo639}640 641define i8 @ashr_constant_sel_constants(i1 %cond) {642; ALL-LABEL: ashr_constant_sel_constants:643; ALL: # %bb.0:644; ALL-NEXT: clrlwi 3, 3, 31645; ALL-NEXT: li 4, -128646; ALL-NEXT: xori 3, 3, 3647; ALL-NEXT: sraw 3, 4, 3648; ALL-NEXT: blr649 %sel = select i1 %cond, i8 2, i8 3650 %bo = ashr i8 128, %sel651 ret i8 %bo652}653 654define double @sel_constants_fadd_constant(i1 %cond) {655; ISEL-LABEL: sel_constants_fadd_constant:656; ISEL: # %bb.0:657; ISEL-NEXT: andi. 3, 3, 1658; ISEL-NEXT: addis 3, 2, .LCPI42_0@toc@ha659; ISEL-NEXT: addis 4, 2, .LCPI42_1@toc@ha660; ISEL-NEXT: addi 3, 3, .LCPI42_0@toc@l661; ISEL-NEXT: addi 4, 4, .LCPI42_1@toc@l662; ISEL-NEXT: iselgt 3, 4, 3663; ISEL-NEXT: lfd 1, 0(3)664; ISEL-NEXT: blr665;666; NO_ISEL-LABEL: sel_constants_fadd_constant:667; NO_ISEL: # %bb.0:668; NO_ISEL-NEXT: andi. 3, 3, 1669; NO_ISEL-NEXT: bc 12, 1, .LBB42_2670; NO_ISEL-NEXT: # %bb.1:671; NO_ISEL-NEXT: addis 3, 2, .LCPI42_0@toc@ha672; NO_ISEL-NEXT: addi 3, 3, .LCPI42_0@toc@l673; NO_ISEL-NEXT: lfd 1, 0(3)674; NO_ISEL-NEXT: blr675; NO_ISEL-NEXT: .LBB42_2:676; NO_ISEL-NEXT: addis 3, 2, .LCPI42_1@toc@ha677; NO_ISEL-NEXT: addi 3, 3, .LCPI42_1@toc@l678; NO_ISEL-NEXT: lfd 1, 0(3)679; NO_ISEL-NEXT: blr680 %sel = select i1 %cond, double -4.0, double 23.3681 %bo = fadd double %sel, 5.1682 ret double %bo683}684 685define double @sel_constants_fsub_constant(i1 %cond) {686; ISEL-LABEL: sel_constants_fsub_constant:687; ISEL: # %bb.0:688; ISEL-NEXT: andi. 3, 3, 1689; ISEL-NEXT: addis 3, 2, .LCPI43_0@toc@ha690; ISEL-NEXT: addis 4, 2, .LCPI43_1@toc@ha691; ISEL-NEXT: addi 3, 3, .LCPI43_0@toc@l692; ISEL-NEXT: addi 4, 4, .LCPI43_1@toc@l693; ISEL-NEXT: iselgt 3, 4, 3694; ISEL-NEXT: lfd 1, 0(3)695; ISEL-NEXT: blr696;697; NO_ISEL-LABEL: sel_constants_fsub_constant:698; NO_ISEL: # %bb.0:699; NO_ISEL-NEXT: andi. 3, 3, 1700; NO_ISEL-NEXT: bc 12, 1, .LBB43_2701; NO_ISEL-NEXT: # %bb.1:702; NO_ISEL-NEXT: addis 3, 2, .LCPI43_0@toc@ha703; NO_ISEL-NEXT: addi 3, 3, .LCPI43_0@toc@l704; NO_ISEL-NEXT: lfd 1, 0(3)705; NO_ISEL-NEXT: blr706; NO_ISEL-NEXT: .LBB43_2:707; NO_ISEL-NEXT: addis 3, 2, .LCPI43_1@toc@ha708; NO_ISEL-NEXT: addi 3, 3, .LCPI43_1@toc@l709; NO_ISEL-NEXT: lfd 1, 0(3)710; NO_ISEL-NEXT: blr711 %sel = select i1 %cond, double -4.0, double 23.3712 %bo = fsub double %sel, 5.1713 ret double %bo714}715 716define double @fsub_constant_sel_constants(i1 %cond) {717; ISEL-LABEL: fsub_constant_sel_constants:718; ISEL: # %bb.0:719; ISEL-NEXT: andi. 3, 3, 1720; ISEL-NEXT: addis 3, 2, .LCPI44_0@toc@ha721; ISEL-NEXT: addis 4, 2, .LCPI44_1@toc@ha722; ISEL-NEXT: addi 3, 3, .LCPI44_0@toc@l723; ISEL-NEXT: addi 4, 4, .LCPI44_1@toc@l724; ISEL-NEXT: iselgt 3, 4, 3725; ISEL-NEXT: lfd 1, 0(3)726; ISEL-NEXT: blr727;728; NO_ISEL-LABEL: fsub_constant_sel_constants:729; NO_ISEL: # %bb.0:730; NO_ISEL-NEXT: andi. 3, 3, 1731; NO_ISEL-NEXT: bc 12, 1, .LBB44_2732; NO_ISEL-NEXT: # %bb.1:733; NO_ISEL-NEXT: addis 3, 2, .LCPI44_0@toc@ha734; NO_ISEL-NEXT: addi 3, 3, .LCPI44_0@toc@l735; NO_ISEL-NEXT: lfd 1, 0(3)736; NO_ISEL-NEXT: blr737; NO_ISEL-NEXT: .LBB44_2:738; NO_ISEL-NEXT: addis 3, 2, .LCPI44_1@toc@ha739; NO_ISEL-NEXT: addi 3, 3, .LCPI44_1@toc@l740; NO_ISEL-NEXT: lfd 1, 0(3)741; NO_ISEL-NEXT: blr742 %sel = select i1 %cond, double -4.0, double 23.3743 %bo = fsub double 5.1, %sel744 ret double %bo745}746 747define double @sel_constants_fmul_constant(i1 %cond) {748; ISEL-LABEL: sel_constants_fmul_constant:749; ISEL: # %bb.0:750; ISEL-NEXT: andi. 3, 3, 1751; ISEL-NEXT: addis 3, 2, .LCPI45_0@toc@ha752; ISEL-NEXT: addis 4, 2, .LCPI45_1@toc@ha753; ISEL-NEXT: addi 3, 3, .LCPI45_0@toc@l754; ISEL-NEXT: addi 4, 4, .LCPI45_1@toc@l755; ISEL-NEXT: iselgt 3, 4, 3756; ISEL-NEXT: lfd 1, 0(3)757; ISEL-NEXT: blr758;759; NO_ISEL-LABEL: sel_constants_fmul_constant:760; NO_ISEL: # %bb.0:761; NO_ISEL-NEXT: andi. 3, 3, 1762; NO_ISEL-NEXT: bc 12, 1, .LBB45_2763; NO_ISEL-NEXT: # %bb.1:764; NO_ISEL-NEXT: addis 3, 2, .LCPI45_0@toc@ha765; NO_ISEL-NEXT: addi 3, 3, .LCPI45_0@toc@l766; NO_ISEL-NEXT: lfd 1, 0(3)767; NO_ISEL-NEXT: blr768; NO_ISEL-NEXT: .LBB45_2:769; NO_ISEL-NEXT: addis 3, 2, .LCPI45_1@toc@ha770; NO_ISEL-NEXT: addi 3, 3, .LCPI45_1@toc@l771; NO_ISEL-NEXT: lfd 1, 0(3)772; NO_ISEL-NEXT: blr773 %sel = select i1 %cond, double -4.0, double 23.3774 %bo = fmul double %sel, 5.1775 ret double %bo776}777 778define double @sel_constants_fdiv_constant(i1 %cond) {779; ISEL-LABEL: sel_constants_fdiv_constant:780; ISEL: # %bb.0:781; ISEL-NEXT: andi. 3, 3, 1782; ISEL-NEXT: addis 3, 2, .LCPI46_0@toc@ha783; ISEL-NEXT: addis 4, 2, .LCPI46_1@toc@ha784; ISEL-NEXT: addi 3, 3, .LCPI46_0@toc@l785; ISEL-NEXT: addi 4, 4, .LCPI46_1@toc@l786; ISEL-NEXT: iselgt 3, 4, 3787; ISEL-NEXT: lfd 1, 0(3)788; ISEL-NEXT: blr789;790; NO_ISEL-LABEL: sel_constants_fdiv_constant:791; NO_ISEL: # %bb.0:792; NO_ISEL-NEXT: andi. 3, 3, 1793; NO_ISEL-NEXT: bc 12, 1, .LBB46_2794; NO_ISEL-NEXT: # %bb.1:795; NO_ISEL-NEXT: addis 3, 2, .LCPI46_0@toc@ha796; NO_ISEL-NEXT: addi 3, 3, .LCPI46_0@toc@l797; NO_ISEL-NEXT: lfd 1, 0(3)798; NO_ISEL-NEXT: blr799; NO_ISEL-NEXT: .LBB46_2:800; NO_ISEL-NEXT: addis 3, 2, .LCPI46_1@toc@ha801; NO_ISEL-NEXT: addi 3, 3, .LCPI46_1@toc@l802; NO_ISEL-NEXT: lfd 1, 0(3)803; NO_ISEL-NEXT: blr804 %sel = select i1 %cond, double -4.0, double 23.3805 %bo = fdiv double %sel, 5.1806 ret double %bo807}808 809define double @fdiv_constant_sel_constants(i1 %cond) {810; ISEL-LABEL: fdiv_constant_sel_constants:811; ISEL: # %bb.0:812; ISEL-NEXT: andi. 3, 3, 1813; ISEL-NEXT: addis 3, 2, .LCPI47_0@toc@ha814; ISEL-NEXT: addis 4, 2, .LCPI47_1@toc@ha815; ISEL-NEXT: addi 3, 3, .LCPI47_0@toc@l816; ISEL-NEXT: addi 4, 4, .LCPI47_1@toc@l817; ISEL-NEXT: iselgt 3, 4, 3818; ISEL-NEXT: lfd 1, 0(3)819; ISEL-NEXT: blr820;821; NO_ISEL-LABEL: fdiv_constant_sel_constants:822; NO_ISEL: # %bb.0:823; NO_ISEL-NEXT: andi. 3, 3, 1824; NO_ISEL-NEXT: bc 12, 1, .LBB47_2825; NO_ISEL-NEXT: # %bb.1:826; NO_ISEL-NEXT: addis 3, 2, .LCPI47_0@toc@ha827; NO_ISEL-NEXT: addi 3, 3, .LCPI47_0@toc@l828; NO_ISEL-NEXT: lfd 1, 0(3)829; NO_ISEL-NEXT: blr830; NO_ISEL-NEXT: .LBB47_2:831; NO_ISEL-NEXT: addis 3, 2, .LCPI47_1@toc@ha832; NO_ISEL-NEXT: addi 3, 3, .LCPI47_1@toc@l833; NO_ISEL-NEXT: lfd 1, 0(3)834; NO_ISEL-NEXT: blr835 %sel = select i1 %cond, double -4.0, double 23.3836 %bo = fdiv double 5.1, %sel837 ret double %bo838}839 840define double @sel_constants_frem_constant(i1 %cond) {841; ALL-LABEL: sel_constants_frem_constant:842; ALL: # %bb.0:843; ALL-NEXT: andi. 3, 3, 1844; ALL-NEXT: bc 12, 1, .LBB48_2845; ALL-NEXT: # %bb.1:846; ALL-NEXT: addis 3, 2, .LCPI48_0@toc@ha847; ALL-NEXT: lfd 1, .LCPI48_0@toc@l(3)848; ALL-NEXT: blr849; ALL-NEXT: .LBB48_2:850; ALL-NEXT: vspltisw 2, -4851; ALL-NEXT: xvcvsxwdp 1, 34852; ALL-NEXT: blr853 %sel = select i1 %cond, double -4.0, double 23.3854 %bo = frem double %sel, 5.1855 ret double %bo856}857 858define double @frem_constant_sel_constants(i1 %cond) {859; ISEL-LABEL: frem_constant_sel_constants:860; ISEL: # %bb.0:861; ISEL-NEXT: andi. 3, 3, 1862; ISEL-NEXT: addis 3, 2, .LCPI49_0@toc@ha863; ISEL-NEXT: addis 4, 2, .LCPI49_1@toc@ha864; ISEL-NEXT: addi 3, 3, .LCPI49_0@toc@l865; ISEL-NEXT: addi 4, 4, .LCPI49_1@toc@l866; ISEL-NEXT: iselgt 3, 4, 3867; ISEL-NEXT: lfd 1, 0(3)868; ISEL-NEXT: blr869;870; NO_ISEL-LABEL: frem_constant_sel_constants:871; NO_ISEL: # %bb.0:872; NO_ISEL-NEXT: andi. 3, 3, 1873; NO_ISEL-NEXT: bc 12, 1, .LBB49_2874; NO_ISEL-NEXT: # %bb.1:875; NO_ISEL-NEXT: addis 3, 2, .LCPI49_0@toc@ha876; NO_ISEL-NEXT: addi 3, 3, .LCPI49_0@toc@l877; NO_ISEL-NEXT: lfd 1, 0(3)878; NO_ISEL-NEXT: blr879; NO_ISEL-NEXT: .LBB49_2:880; NO_ISEL-NEXT: addis 3, 2, .LCPI49_1@toc@ha881; NO_ISEL-NEXT: addi 3, 3, .LCPI49_1@toc@l882; NO_ISEL-NEXT: lfd 1, 0(3)883; NO_ISEL-NEXT: blr884 %sel = select i1 %cond, double -4.0, double 23.3885 %bo = frem double 5.1, %sel886 ret double %bo887}888