571 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov,+bmi | FileCheck %s --check-prefix=X863; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+cmov,+bmi | FileCheck %s --check-prefix=X644 5define i32 @blsmsk_used2(i32 %a) nounwind {6; X86-LABEL: blsmsk_used2:7; X86: # %bb.0: # %entry8; X86-NEXT: movl {{[0-9]+}}(%esp), %eax9; X86-NEXT: leal -1(%eax), %ecx10; X86-NEXT: xorl %ecx, %eax11; X86-NEXT: imull %ecx, %eax12; X86-NEXT: retl13;14; X64-LABEL: blsmsk_used2:15; X64: # %bb.0: # %entry16; X64-NEXT: # kill: def $edi killed $edi def $rdi17; X64-NEXT: leal -1(%rdi), %eax18; X64-NEXT: xorl %eax, %edi19; X64-NEXT: imull %edi, %eax20; X64-NEXT: retq21entry:22 %sub = add i32 %a, -123 %xor = xor i32 %sub, %a24 %mul = mul i32 %xor, %sub25 ret i32 %mul26}27 28define i64 @blsmask_through1(i64 %a, i64 %b) nounwind {29; X86-LABEL: blsmask_through1:30; X86: # %bb.0: # %entry31; X86-NEXT: pushl %esi32; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx33; X86-NEXT: movl {{[0-9]+}}(%esp), %esi34; X86-NEXT: movl %ecx, %eax35; X86-NEXT: addl $-1, %eax36; X86-NEXT: movl %esi, %edx37; X86-NEXT: adcl $-1, %edx38; X86-NEXT: xorl {{[0-9]+}}(%esp), %edx39; X86-NEXT: xorl {{[0-9]+}}(%esp), %eax40; X86-NEXT: xorl %ecx, %eax41; X86-NEXT: xorl %esi, %edx42; X86-NEXT: popl %esi43; X86-NEXT: retl44;45; X64-LABEL: blsmask_through1:46; X64: # %bb.0: # %entry47; X64-NEXT: blsmskq %rsi, %rax48; X64-NEXT: xorq %rdi, %rax49; X64-NEXT: retq50entry:51 %sub = add i64 %b, -152 %0 = xor i64 %sub, %a53 %xor1 = xor i64 %0, %b54 ret i64 %xor155}56 57define i32 @blsmask_through2(i32 %a, i32 %b, i32 %c) nounwind {58; X86-LABEL: blsmask_through2:59; X86: # %bb.0: # %entry60; X86-NEXT: blsmskl {{[0-9]+}}(%esp), %eax61; X86-NEXT: xorl {{[0-9]+}}(%esp), %eax62; X86-NEXT: xorl {{[0-9]+}}(%esp), %eax63; X86-NEXT: retl64;65; X64-LABEL: blsmask_through2:66; X64: # %bb.0: # %entry67; X64-NEXT: blsmskl %esi, %eax68; X64-NEXT: xorl %edx, %edi69; X64-NEXT: xorl %edi, %eax70; X64-NEXT: retq71entry:72 %sub = add nsw i32 %b, -173 %0 = xor i32 %sub, %a74 %1 = xor i32 %0, %c75 %xor2 = xor i32 %1, %b76 ret i32 %xor277}78 79define i64 @blsmask_through3(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {80; X86-LABEL: blsmask_through3:81; X86: # %bb.0: # %entry82; X86-NEXT: pushl %esi83; X86-NEXT: movl {{[0-9]+}}(%esp), %esi84; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx85; X86-NEXT: movl %esi, %eax86; X86-NEXT: addl $-1, %eax87; X86-NEXT: movl %ecx, %edx88; X86-NEXT: adcl $-1, %edx89; X86-NEXT: xorl {{[0-9]+}}(%esp), %edx90; X86-NEXT: xorl {{[0-9]+}}(%esp), %eax91; X86-NEXT: xorl {{[0-9]+}}(%esp), %edx92; X86-NEXT: xorl {{[0-9]+}}(%esp), %eax93; X86-NEXT: xorl {{[0-9]+}}(%esp), %edx94; X86-NEXT: xorl {{[0-9]+}}(%esp), %eax95; X86-NEXT: xorl %esi, %eax96; X86-NEXT: xorl %ecx, %edx97; X86-NEXT: popl %esi98; X86-NEXT: retl99;100; X64-LABEL: blsmask_through3:101; X64: # %bb.0: # %entry102; X64-NEXT: leaq -1(%rsi), %rax103; X64-NEXT: xorq %rdx, %rdi104; X64-NEXT: xorq %rdi, %rax105; X64-NEXT: xorq %rsi, %rcx106; X64-NEXT: xorq %rcx, %rax107; X64-NEXT: retq108entry:109 %sub = add nsw i64 %b, -1110 %0 = xor i64 %sub, %a111 %1 = xor i64 %0, %c112 %2 = xor i64 %1, %d113 %xor3 = xor i64 %2, %b114 ret i64 %xor3115}116 117define i32 @blsmask_through1_used1(i32 %a, i32 %b) nounwind {118; X86-LABEL: blsmask_through1_used1:119; X86: # %bb.0: # %entry120; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx121; X86-NEXT: leal -1(%ecx), %eax122; X86-NEXT: xorl {{[0-9]+}}(%esp), %eax123; X86-NEXT: xorl %eax, %ecx124; X86-NEXT: incl %eax125; X86-NEXT: orl %ecx, %eax126; X86-NEXT: retl127;128; X64-LABEL: blsmask_through1_used1:129; X64: # %bb.0: # %entry130; X64-NEXT: # kill: def $esi killed $esi def $rsi131; X64-NEXT: leal -1(%rsi), %eax132; X64-NEXT: xorl %edi, %eax133; X64-NEXT: xorl %eax, %esi134; X64-NEXT: incl %eax135; X64-NEXT: orl %esi, %eax136; X64-NEXT: retq137entry:138 %sub = add i32 %b, -1139 %xor = xor i32 %sub, %a140 %xor1 = xor i32 %xor, %b141 %add = add i32 %xor, 1142 %or = or i32 %add, %xor1143 ret i32 %or144}145 146define i64 @blsmask_through1_used2(i64 %a, i64 %b) nounwind {147; X86-LABEL: blsmask_through1_used2:148; X86: # %bb.0: # %entry149; X86-NEXT: pushl %ebp150; X86-NEXT: pushl %ebx151; X86-NEXT: pushl %edi152; X86-NEXT: pushl %esi153; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx154; X86-NEXT: movl {{[0-9]+}}(%esp), %esi155; X86-NEXT: movl %ecx, %edi156; X86-NEXT: addl $-1, %edi157; X86-NEXT: movl %esi, %ebp158; X86-NEXT: adcl $-1, %ebp159; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx160; X86-NEXT: xorl %ebp, %ebx161; X86-NEXT: movl {{[0-9]+}}(%esp), %eax162; X86-NEXT: xorl %edi, %eax163; X86-NEXT: xorl %ebx, %esi164; X86-NEXT: xorl %eax, %ecx165; X86-NEXT: imull %eax, %ebp166; X86-NEXT: mull %edi167; X86-NEXT: addl %ebp, %edx168; X86-NEXT: imull %edi, %ebx169; X86-NEXT: addl %ebx, %edx170; X86-NEXT: orl %esi, %edx171; X86-NEXT: orl %ecx, %eax172; X86-NEXT: popl %esi173; X86-NEXT: popl %edi174; X86-NEXT: popl %ebx175; X86-NEXT: popl %ebp176; X86-NEXT: retl177;178; X64-LABEL: blsmask_through1_used2:179; X64: # %bb.0: # %entry180; X64-NEXT: leaq -1(%rsi), %rax181; X64-NEXT: xorq %rax, %rdi182; X64-NEXT: xorq %rdi, %rsi183; X64-NEXT: imulq %rdi, %rax184; X64-NEXT: orq %rsi, %rax185; X64-NEXT: retq186entry:187 %sub = add i64 %b, -1188 %xor = xor i64 %sub, %a189 %xor1 = xor i64 %xor, %b190 %mul = mul i64 %xor, %sub191 %or = or i64 %mul, %xor1192 ret i64 %or193}194 195define i32 @blsi_used2(i32 %a) nounwind {196; X86-LABEL: blsi_used2:197; X86: # %bb.0: # %entry198; X86-NEXT: movl {{[0-9]+}}(%esp), %eax199; X86-NEXT: movl %eax, %ecx200; X86-NEXT: negl %ecx201; X86-NEXT: andl %ecx, %eax202; X86-NEXT: imull %ecx, %eax203; X86-NEXT: retl204;205; X64-LABEL: blsi_used2:206; X64: # %bb.0: # %entry207; X64-NEXT: movl %edi, %eax208; X64-NEXT: negl %eax209; X64-NEXT: andl %eax, %edi210; X64-NEXT: imull %edi, %eax211; X64-NEXT: retq212entry:213 %sub = sub nsw i32 0, %a214 %and = and i32 %sub, %a215 %mul = mul nsw i32 %and, %sub216 ret i32 %mul217}218 219define i64 @blsi_through1(i64 %a, i64 %b) nounwind {220; X86-LABEL: blsi_through1:221; X86: # %bb.0: # %entry222; X86-NEXT: pushl %esi223; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx224; X86-NEXT: movl {{[0-9]+}}(%esp), %esi225; X86-NEXT: xorl %edx, %edx226; X86-NEXT: movl %ecx, %eax227; X86-NEXT: negl %eax228; X86-NEXT: sbbl %esi, %edx229; X86-NEXT: andl {{[0-9]+}}(%esp), %edx230; X86-NEXT: andl {{[0-9]+}}(%esp), %eax231; X86-NEXT: andl %esi, %edx232; X86-NEXT: andl %ecx, %eax233; X86-NEXT: popl %esi234; X86-NEXT: retl235;236; X64-LABEL: blsi_through1:237; X64: # %bb.0: # %entry238; X64-NEXT: blsiq %rsi, %rax239; X64-NEXT: andq %rdi, %rax240; X64-NEXT: retq241entry:242 %sub = sub nsw i64 0, %b243 %and = and i64 %sub, %a244 %and1 = and i64 %and, %b245 ret i64 %and1246}247 248define i32 @blsi_through2(i32 %a, i32 %b, i32 %c) nounwind {249; X86-LABEL: blsi_through2:250; X86: # %bb.0: # %entry251; X86-NEXT: blsil {{[0-9]+}}(%esp), %eax252; X86-NEXT: andl {{[0-9]+}}(%esp), %eax253; X86-NEXT: andl {{[0-9]+}}(%esp), %eax254; X86-NEXT: retl255;256; X64-LABEL: blsi_through2:257; X64: # %bb.0: # %entry258; X64-NEXT: blsil %esi, %eax259; X64-NEXT: andl %edx, %edi260; X64-NEXT: andl %edi, %eax261; X64-NEXT: retq262entry:263 %sub = sub i32 0, %b264 %and = and i32 %sub, %a265 %0 = and i32 %and, %c266 %and2 = and i32 %0, %b267 ret i32 %and2268}269 270define i64 @blsi_through3(i64 %a, i64 %b, i64 %c) nounwind {271; X86-LABEL: blsi_through3:272; X86: # %bb.0: # %entry273; X86-NEXT: pushl %esi274; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx275; X86-NEXT: movl {{[0-9]+}}(%esp), %esi276; X86-NEXT: xorl %edx, %edx277; X86-NEXT: movl %ecx, %eax278; X86-NEXT: negl %eax279; X86-NEXT: sbbl %esi, %edx280; X86-NEXT: andl {{[0-9]+}}(%esp), %edx281; X86-NEXT: andl {{[0-9]+}}(%esp), %eax282; X86-NEXT: andl {{[0-9]+}}(%esp), %edx283; X86-NEXT: andl {{[0-9]+}}(%esp), %eax284; X86-NEXT: andl %esi, %edx285; X86-NEXT: andl %ecx, %eax286; X86-NEXT: popl %esi287; X86-NEXT: retl288;289; X64-LABEL: blsi_through3:290; X64: # %bb.0: # %entry291; X64-NEXT: blsiq %rsi, %rax292; X64-NEXT: andq %rdx, %rdi293; X64-NEXT: andq %rdi, %rax294; X64-NEXT: retq295entry:296 %sub = sub i64 0, %b297 %and = and i64 %sub, %a298 %0 = and i64 %and, %c299 %and3 = and i64 %0, %b300 ret i64 %and3301}302 303define i32 @blsi_through1_used1(i32 %a, i32 %b) nounwind {304; X86-LABEL: blsi_through1_used1:305; X86: # %bb.0: # %entry306; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx307; X86-NEXT: movl %ecx, %eax308; X86-NEXT: negl %eax309; X86-NEXT: andl {{[0-9]+}}(%esp), %eax310; X86-NEXT: andl %eax, %ecx311; X86-NEXT: incl %eax312; X86-NEXT: orl %ecx, %eax313; X86-NEXT: retl314;315; X64-LABEL: blsi_through1_used1:316; X64: # %bb.0: # %entry317; X64-NEXT: movl %esi, %eax318; X64-NEXT: negl %eax319; X64-NEXT: andl %edi, %eax320; X64-NEXT: andl %eax, %esi321; X64-NEXT: incl %eax322; X64-NEXT: orl %esi, %eax323; X64-NEXT: retq324entry:325 %sub = sub nsw i32 0, %b326 %and = and i32 %sub, %a327 %and1 = and i32 %and, %b328 %add = add nsw i32 %and, 1329 %or = or i32 %add, %and1330 ret i32 %or331}332 333define i64 @blsi_through1_used2(i64 %a, i64 %b) nounwind {334; X86-LABEL: blsi_through1_used2:335; X86: # %bb.0: # %entry336; X86-NEXT: pushl %ebx337; X86-NEXT: pushl %edi338; X86-NEXT: pushl %esi339; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx340; X86-NEXT: movl {{[0-9]+}}(%esp), %esi341; X86-NEXT: xorl %edi, %edi342; X86-NEXT: movl %ecx, %edx343; X86-NEXT: negl %edx344; X86-NEXT: sbbl %esi, %edi345; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx346; X86-NEXT: andl %edi, %ebx347; X86-NEXT: movl {{[0-9]+}}(%esp), %eax348; X86-NEXT: andl %edx, %eax349; X86-NEXT: andl %ebx, %esi350; X86-NEXT: andl %eax, %ecx351; X86-NEXT: imull %edx, %ebx352; X86-NEXT: imull %eax, %edi353; X86-NEXT: mull %edx354; X86-NEXT: addl %edi, %edx355; X86-NEXT: addl %ebx, %edx356; X86-NEXT: orl %esi, %edx357; X86-NEXT: orl %ecx, %eax358; X86-NEXT: popl %esi359; X86-NEXT: popl %edi360; X86-NEXT: popl %ebx361; X86-NEXT: retl362;363; X64-LABEL: blsi_through1_used2:364; X64: # %bb.0: # %entry365; X64-NEXT: movq %rsi, %rax366; X64-NEXT: negq %rax367; X64-NEXT: andq %rax, %rdi368; X64-NEXT: andq %rdi, %rsi369; X64-NEXT: imulq %rdi, %rax370; X64-NEXT: orq %rsi, %rax371; X64-NEXT: retq372entry:373 %sub = sub nsw i64 0, %b374 %and = and i64 %sub, %a375 %and1 = and i64 %and, %b376 %mul = mul nsw i64 %and, %sub377 %or = or i64 %mul, %and1378 ret i64 %or379}380 381define i32 @blsr_used2(i32 %a) nounwind {382; X86-LABEL: blsr_used2:383; X86: # %bb.0: # %entry384; X86-NEXT: movl {{[0-9]+}}(%esp), %eax385; X86-NEXT: leal -1(%eax), %ecx386; X86-NEXT: andl %ecx, %eax387; X86-NEXT: imull %ecx, %eax388; X86-NEXT: retl389;390; X64-LABEL: blsr_used2:391; X64: # %bb.0: # %entry392; X64-NEXT: # kill: def $edi killed $edi def $rdi393; X64-NEXT: leal -1(%rdi), %eax394; X64-NEXT: andl %eax, %edi395; X64-NEXT: imull %edi, %eax396; X64-NEXT: retq397entry:398 %sub = add i32 %a, -1399 %and = and i32 %sub, %a400 %mul = mul i32 %and, %sub401 ret i32 %mul402}403 404define i64 @blsr_through1(i64 %a, i64 %b) nounwind {405; X86-LABEL: blsr_through1:406; X86: # %bb.0: # %entry407; X86-NEXT: pushl %esi408; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx409; X86-NEXT: movl {{[0-9]+}}(%esp), %esi410; X86-NEXT: movl %ecx, %eax411; X86-NEXT: addl $-1, %eax412; X86-NEXT: movl %esi, %edx413; X86-NEXT: adcl $-1, %edx414; X86-NEXT: andl {{[0-9]+}}(%esp), %edx415; X86-NEXT: andl {{[0-9]+}}(%esp), %eax416; X86-NEXT: andl %ecx, %eax417; X86-NEXT: andl %esi, %edx418; X86-NEXT: popl %esi419; X86-NEXT: retl420;421; X64-LABEL: blsr_through1:422; X64: # %bb.0: # %entry423; X64-NEXT: blsrq %rsi, %rax424; X64-NEXT: andq %rdi, %rax425; X64-NEXT: retq426entry:427 %sub = add i64 %b, -1428 %0 = and i64 %sub, %a429 %and1 = and i64 %0, %b430 ret i64 %and1431}432 433define i32 @blsr_through2(i32 %a, i32 %b, i32 %c) nounwind {434; X86-LABEL: blsr_through2:435; X86: # %bb.0: # %entry436; X86-NEXT: blsrl {{[0-9]+}}(%esp), %eax437; X86-NEXT: andl {{[0-9]+}}(%esp), %eax438; X86-NEXT: andl {{[0-9]+}}(%esp), %eax439; X86-NEXT: retl440;441; X64-LABEL: blsr_through2:442; X64: # %bb.0: # %entry443; X64-NEXT: blsrl %esi, %eax444; X64-NEXT: andl %edx, %edi445; X64-NEXT: andl %edi, %eax446; X64-NEXT: retq447entry:448 %sub = add nsw i32 %b, -1449 %0 = and i32 %sub, %a450 %1 = and i32 %0, %c451 %and2 = and i32 %1, %b452 ret i32 %and2453}454 455define i64 @blsr_through3(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {456; X86-LABEL: blsr_through3:457; X86: # %bb.0: # %entry458; X86-NEXT: pushl %esi459; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx460; X86-NEXT: movl {{[0-9]+}}(%esp), %esi461; X86-NEXT: xorl %edx, %edx462; X86-NEXT: movl %ecx, %eax463; X86-NEXT: negl %eax464; X86-NEXT: sbbl %esi, %edx465; X86-NEXT: andl {{[0-9]+}}(%esp), %edx466; X86-NEXT: andl {{[0-9]+}}(%esp), %eax467; X86-NEXT: andl {{[0-9]+}}(%esp), %edx468; X86-NEXT: andl {{[0-9]+}}(%esp), %eax469; X86-NEXT: andl {{[0-9]+}}(%esp), %edx470; X86-NEXT: andl {{[0-9]+}}(%esp), %eax471; X86-NEXT: andl %esi, %edx472; X86-NEXT: andl %ecx, %eax473; X86-NEXT: popl %esi474; X86-NEXT: retl475;476; X64-LABEL: blsr_through3:477; X64: # %bb.0: # %entry478; X64-NEXT: movq %rdi, %rax479; X64-NEXT: andq %rsi, %rcx480; X64-NEXT: negq %rsi481; X64-NEXT: andq %rdx, %rax482; X64-NEXT: andq %rsi, %rax483; X64-NEXT: andq %rcx, %rax484; X64-NEXT: retq485entry:486 %sub = sub nsw i64 0, %b487 %and = and i64 %sub, %a488 %0 = and i64 %and, %c489 %1 = and i64 %0, %d490 %and4 = and i64 %1, %b491 ret i64 %and4492}493 494define i32 @blsr_through1_used1(i32 %a, i32 %b) nounwind {495; X86-LABEL: blsr_through1_used1:496; X86: # %bb.0: # %entry497; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx498; X86-NEXT: leal -1(%ecx), %eax499; X86-NEXT: andl {{[0-9]+}}(%esp), %eax500; X86-NEXT: andl %eax, %ecx501; X86-NEXT: incl %eax502; X86-NEXT: orl %ecx, %eax503; X86-NEXT: retl504;505; X64-LABEL: blsr_through1_used1:506; X64: # %bb.0: # %entry507; X64-NEXT: # kill: def $esi killed $esi def $rsi508; X64-NEXT: leal -1(%rsi), %eax509; X64-NEXT: andl %edi, %eax510; X64-NEXT: andl %eax, %esi511; X64-NEXT: incl %eax512; X64-NEXT: orl %esi, %eax513; X64-NEXT: retq514entry:515 %sub = add i32 %b, -1516 %and = and i32 %sub, %a517 %and1 = and i32 %and, %b518 %add = add i32 %and, 1519 %or = or i32 %add, %and1520 ret i32 %or521}522 523define i64 @blsr_through1_used2(i64 %a, i64 %b) nounwind {524; X86-LABEL: blsr_through1_used2:525; X86: # %bb.0: # %entry526; X86-NEXT: pushl %ebp527; X86-NEXT: pushl %ebx528; X86-NEXT: pushl %edi529; X86-NEXT: pushl %esi530; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx531; X86-NEXT: movl {{[0-9]+}}(%esp), %esi532; X86-NEXT: movl %ecx, %edi533; X86-NEXT: addl $-1, %edi534; X86-NEXT: movl %esi, %ebp535; X86-NEXT: adcl $-1, %ebp536; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx537; X86-NEXT: andl %ebp, %ebx538; X86-NEXT: movl {{[0-9]+}}(%esp), %eax539; X86-NEXT: andl %edi, %eax540; X86-NEXT: andl %ebx, %esi541; X86-NEXT: andl %eax, %ecx542; X86-NEXT: imull %eax, %ebp543; X86-NEXT: mull %edi544; X86-NEXT: addl %ebp, %edx545; X86-NEXT: imull %edi, %ebx546; X86-NEXT: addl %ebx, %edx547; X86-NEXT: orl %esi, %edx548; X86-NEXT: orl %ecx, %eax549; X86-NEXT: popl %esi550; X86-NEXT: popl %edi551; X86-NEXT: popl %ebx552; X86-NEXT: popl %ebp553; X86-NEXT: retl554;555; X64-LABEL: blsr_through1_used2:556; X64: # %bb.0: # %entry557; X64-NEXT: leaq -1(%rsi), %rax558; X64-NEXT: andq %rax, %rdi559; X64-NEXT: andq %rdi, %rsi560; X64-NEXT: imulq %rdi, %rax561; X64-NEXT: orq %rsi, %rax562; X64-NEXT: retq563entry:564 %sub = add i64 %b, -1565 %and = and i64 %sub, %a566 %and1 = and i64 %and, %b567 %mul = mul i64 %and, %sub568 %or = or i64 %mul, %and1569 ret i64 %or570}571