213 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-bmi,-tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI3; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+tbm,+bmi2 < %s | FileCheck %s --check-prefixes=X86-BMI24; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,-tbm,+bmi2 < %s | FileCheck %s --check-prefixes=X86-BMI25; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=-bmi,-tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X64-NOBMI6; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,+tbm,+bmi2 < %s | FileCheck %s --check-prefixes=X64-BMI27; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,-tbm,+bmi2 < %s | FileCheck %s --check-prefixes=X64-BMI28 9define i32 @mask_pair(i32 %x, i32 %y) nounwind {10; X86-NOBMI-LABEL: mask_pair:11; X86-NOBMI: # %bb.0:12; X86-NOBMI-NEXT: movzbl {{[0-9]+}}(%esp), %ecx13; X86-NOBMI-NEXT: movl {{[0-9]+}}(%esp), %eax14; X86-NOBMI-NEXT: shrl %cl, %eax15; X86-NOBMI-NEXT: shll %cl, %eax16; X86-NOBMI-NEXT: retl17;18; X86-BMI2-LABEL: mask_pair:19; X86-BMI2: # %bb.0:20; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %eax21; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %ecx22; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax23; X86-BMI2-NEXT: retl24;25; X64-NOBMI-LABEL: mask_pair:26; X64-NOBMI: # %bb.0:27; X64-NOBMI-NEXT: movl %esi, %ecx28; X64-NOBMI-NEXT: movl %edi, %eax29; X64-NOBMI-NEXT: shrl %cl, %eax30; X64-NOBMI-NEXT: # kill: def $cl killed $cl killed $ecx31; X64-NOBMI-NEXT: shll %cl, %eax32; X64-NOBMI-NEXT: retq33;34; X64-BMI2-LABEL: mask_pair:35; X64-BMI2: # %bb.0:36; X64-BMI2-NEXT: shrxl %esi, %edi, %eax37; X64-BMI2-NEXT: shlxl %esi, %eax, %eax38; X64-BMI2-NEXT: retq39 %shl = shl nsw i32 -1, %y40 %and = and i32 %shl, %x41 ret i32 %and42}43 44define i64 @mask_pair_64(i64 %x, i64 %y) nounwind {45; X86-NOBMI-LABEL: mask_pair_64:46; X86-NOBMI: # %bb.0:47; X86-NOBMI-NEXT: movzbl {{[0-9]+}}(%esp), %ecx48; X86-NOBMI-NEXT: movl $-1, %edx49; X86-NOBMI-NEXT: movl $-1, %eax50; X86-NOBMI-NEXT: shll %cl, %eax51; X86-NOBMI-NEXT: testb $32, %cl52; X86-NOBMI-NEXT: je .LBB1_253; X86-NOBMI-NEXT: # %bb.1:54; X86-NOBMI-NEXT: movl %eax, %edx55; X86-NOBMI-NEXT: xorl %eax, %eax56; X86-NOBMI-NEXT: .LBB1_2:57; X86-NOBMI-NEXT: andl {{[0-9]+}}(%esp), %eax58; X86-NOBMI-NEXT: andl {{[0-9]+}}(%esp), %edx59; X86-NOBMI-NEXT: retl60;61; X86-BMI2-LABEL: mask_pair_64:62; X86-BMI2: # %bb.0:63; X86-BMI2-NEXT: movzbl {{[0-9]+}}(%esp), %ecx64; X86-BMI2-NEXT: movl $-1, %edx65; X86-BMI2-NEXT: shlxl %ecx, %edx, %eax66; X86-BMI2-NEXT: testb $32, %cl67; X86-BMI2-NEXT: je .LBB1_268; X86-BMI2-NEXT: # %bb.1:69; X86-BMI2-NEXT: movl %eax, %edx70; X86-BMI2-NEXT: xorl %eax, %eax71; X86-BMI2-NEXT: .LBB1_2:72; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax73; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx74; X86-BMI2-NEXT: retl75;76; X64-NOBMI-LABEL: mask_pair_64:77; X64-NOBMI: # %bb.0:78; X64-NOBMI-NEXT: movq %rsi, %rcx79; X64-NOBMI-NEXT: movq %rdi, %rax80; X64-NOBMI-NEXT: shrq %cl, %rax81; X64-NOBMI-NEXT: # kill: def $cl killed $cl killed $rcx82; X64-NOBMI-NEXT: shlq %cl, %rax83; X64-NOBMI-NEXT: retq84;85; X64-BMI2-LABEL: mask_pair_64:86; X64-BMI2: # %bb.0:87; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax88; X64-BMI2-NEXT: shlxq %rsi, %rax, %rax89; X64-BMI2-NEXT: retq90 %shl = shl nsw i64 -1, %y91 %and = and i64 %shl, %x92 ret i64 %and93}94 95define i128 @mask_pair_128(i128 %x, i128 %y) nounwind {96; X86-NOBMI-LABEL: mask_pair_128:97; X86-NOBMI: # %bb.0:98; X86-NOBMI-NEXT: pushl %ebx99; X86-NOBMI-NEXT: pushl %edi100; X86-NOBMI-NEXT: pushl %esi101; X86-NOBMI-NEXT: subl $32, %esp102; X86-NOBMI-NEXT: movl {{[0-9]+}}(%esp), %ecx103; X86-NOBMI-NEXT: movl {{[0-9]+}}(%esp), %eax104; X86-NOBMI-NEXT: movl $-1, {{[0-9]+}}(%esp)105; X86-NOBMI-NEXT: movl $-1, {{[0-9]+}}(%esp)106; X86-NOBMI-NEXT: movl $-1, {{[0-9]+}}(%esp)107; X86-NOBMI-NEXT: movl $-1, {{[0-9]+}}(%esp)108; X86-NOBMI-NEXT: movl $0, {{[0-9]+}}(%esp)109; X86-NOBMI-NEXT: movl $0, {{[0-9]+}}(%esp)110; X86-NOBMI-NEXT: movl $0, {{[0-9]+}}(%esp)111; X86-NOBMI-NEXT: movl $0, (%esp)112; X86-NOBMI-NEXT: movl %ecx, %edx113; X86-NOBMI-NEXT: shrb $3, %dl114; X86-NOBMI-NEXT: andb $12, %dl115; X86-NOBMI-NEXT: negb %dl116; X86-NOBMI-NEXT: movsbl %dl, %ebx117; X86-NOBMI-NEXT: movl 24(%esp,%ebx), %edx118; X86-NOBMI-NEXT: movl 28(%esp,%ebx), %esi119; X86-NOBMI-NEXT: shldl %cl, %edx, %esi120; X86-NOBMI-NEXT: movl 16(%esp,%ebx), %edi121; X86-NOBMI-NEXT: movl 20(%esp,%ebx), %ebx122; X86-NOBMI-NEXT: shldl %cl, %ebx, %edx123; X86-NOBMI-NEXT: shldl %cl, %edi, %ebx124; X86-NOBMI-NEXT: # kill: def $cl killed $cl killed $ecx125; X86-NOBMI-NEXT: shll %cl, %edi126; X86-NOBMI-NEXT: andl {{[0-9]+}}(%esp), %edx127; X86-NOBMI-NEXT: andl {{[0-9]+}}(%esp), %esi128; X86-NOBMI-NEXT: andl {{[0-9]+}}(%esp), %edi129; X86-NOBMI-NEXT: andl {{[0-9]+}}(%esp), %ebx130; X86-NOBMI-NEXT: movl %esi, 12(%eax)131; X86-NOBMI-NEXT: movl %edx, 8(%eax)132; X86-NOBMI-NEXT: movl %ebx, 4(%eax)133; X86-NOBMI-NEXT: movl %edi, (%eax)134; X86-NOBMI-NEXT: addl $32, %esp135; X86-NOBMI-NEXT: popl %esi136; X86-NOBMI-NEXT: popl %edi137; X86-NOBMI-NEXT: popl %ebx138; X86-NOBMI-NEXT: retl $4139;140; X86-BMI2-LABEL: mask_pair_128:141; X86-BMI2: # %bb.0:142; X86-BMI2-NEXT: pushl %ebx143; X86-BMI2-NEXT: pushl %edi144; X86-BMI2-NEXT: pushl %esi145; X86-BMI2-NEXT: subl $32, %esp146; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx147; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax148; X86-BMI2-NEXT: movl $-1, {{[0-9]+}}(%esp)149; X86-BMI2-NEXT: movl $-1, {{[0-9]+}}(%esp)150; X86-BMI2-NEXT: movl $-1, {{[0-9]+}}(%esp)151; X86-BMI2-NEXT: movl $-1, {{[0-9]+}}(%esp)152; X86-BMI2-NEXT: movl $0, {{[0-9]+}}(%esp)153; X86-BMI2-NEXT: movl $0, {{[0-9]+}}(%esp)154; X86-BMI2-NEXT: movl $0, {{[0-9]+}}(%esp)155; X86-BMI2-NEXT: movl $0, (%esp)156; X86-BMI2-NEXT: movl %ecx, %edx157; X86-BMI2-NEXT: shrb $3, %dl158; X86-BMI2-NEXT: andb $12, %dl159; X86-BMI2-NEXT: negb %dl160; X86-BMI2-NEXT: movsbl %dl, %edi161; X86-BMI2-NEXT: movl 24(%esp,%edi), %edx162; X86-BMI2-NEXT: movl 28(%esp,%edi), %esi163; X86-BMI2-NEXT: shldl %cl, %edx, %esi164; X86-BMI2-NEXT: movl 16(%esp,%edi), %ebx165; X86-BMI2-NEXT: movl 20(%esp,%edi), %edi166; X86-BMI2-NEXT: shldl %cl, %edi, %edx167; X86-BMI2-NEXT: shldl %cl, %ebx, %edi168; X86-BMI2-NEXT: shlxl %ecx, %ebx, %ecx169; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edx170; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %esi171; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %ecx172; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %edi173; X86-BMI2-NEXT: movl %esi, 12(%eax)174; X86-BMI2-NEXT: movl %edx, 8(%eax)175; X86-BMI2-NEXT: movl %edi, 4(%eax)176; X86-BMI2-NEXT: movl %ecx, (%eax)177; X86-BMI2-NEXT: addl $32, %esp178; X86-BMI2-NEXT: popl %esi179; X86-BMI2-NEXT: popl %edi180; X86-BMI2-NEXT: popl %ebx181; X86-BMI2-NEXT: retl $4182;183; X64-NOBMI-LABEL: mask_pair_128:184; X64-NOBMI: # %bb.0:185; X64-NOBMI-NEXT: movq %rdx, %rcx186; X64-NOBMI-NEXT: movq $-1, %rdx187; X64-NOBMI-NEXT: movq $-1, %r8188; X64-NOBMI-NEXT: shlq %cl, %r8189; X64-NOBMI-NEXT: xorl %eax, %eax190; X64-NOBMI-NEXT: testb $64, %cl191; X64-NOBMI-NEXT: cmovneq %r8, %rdx192; X64-NOBMI-NEXT: cmoveq %r8, %rax193; X64-NOBMI-NEXT: andq %rdi, %rax194; X64-NOBMI-NEXT: andq %rsi, %rdx195; X64-NOBMI-NEXT: retq196;197; X64-BMI2-LABEL: mask_pair_128:198; X64-BMI2: # %bb.0:199; X64-BMI2-NEXT: movq $-1, %rcx200; X64-BMI2-NEXT: shlxq %rdx, %rcx, %r8201; X64-BMI2-NEXT: xorl %eax, %eax202; X64-BMI2-NEXT: testb $64, %dl203; X64-BMI2-NEXT: cmovneq %r8, %rcx204; X64-BMI2-NEXT: cmoveq %r8, %rax205; X64-BMI2-NEXT: andq %rdi, %rax206; X64-BMI2-NEXT: andq %rsi, %rcx207; X64-BMI2-NEXT: movq %rcx, %rdx208; X64-BMI2-NEXT: retq209 %shl = shl nsw i128 -1, %y210 %and = and i128 %shl, %x211 ret i128 %and212}213