721 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefixes=X86,X86-FAST3; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+slow-shld | FileCheck %s --check-prefixes=X86,X86-SLOW4; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=X64,X64-FAST5; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+slow-shld | FileCheck %s --check-prefixes=X64,X64-SLOW6 7declare i8 @llvm.fshl.i8(i8, i8, i8) nounwind readnone8declare i16 @llvm.fshl.i16(i16, i16, i16) nounwind readnone9declare i32 @llvm.fshl.i32(i32, i32, i32) nounwind readnone10declare i64 @llvm.fshl.i64(i64, i64, i64) nounwind readnone11declare i128 @llvm.fshl.i128(i128, i128, i128) nounwind readnone12 13;14; Variable Funnel Shift15;16 17define i8 @var_shift_i8(i8 %x, i8 %y, i8 %z) nounwind {18; X86-LABEL: var_shift_i8:19; X86: # %bb.0:20; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx21; X86-NEXT: movzbl {{[0-9]+}}(%esp), %edx22; X86-NEXT: movl {{[0-9]+}}(%esp), %eax23; X86-NEXT: shll $8, %eax24; X86-NEXT: orl %edx, %eax25; X86-NEXT: andb $7, %cl26; X86-NEXT: shll %cl, %eax27; X86-NEXT: movb %ah, %al28; X86-NEXT: retl29;30; X64-LABEL: var_shift_i8:31; X64: # %bb.0:32; X64-NEXT: movl %edx, %ecx33; X64-NEXT: shll $8, %edi34; X64-NEXT: movzbl %sil, %eax35; X64-NEXT: orl %edi, %eax36; X64-NEXT: andb $7, %cl37; X64-NEXT: # kill: def $cl killed $cl killed $ecx38; X64-NEXT: shll %cl, %eax39; X64-NEXT: shrl $8, %eax40; X64-NEXT: # kill: def $al killed $al killed $eax41; X64-NEXT: retq42 %tmp = tail call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %z)43 ret i8 %tmp44}45 46define i16 @var_shift_i16(i16 %x, i16 %y, i16 %z) nounwind {47; X86-FAST-LABEL: var_shift_i16:48; X86-FAST: # %bb.0:49; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %edx50; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %eax51; X86-FAST-NEXT: movzbl {{[0-9]+}}(%esp), %ecx52; X86-FAST-NEXT: andb $15, %cl53; X86-FAST-NEXT: shldw %cl, %dx, %ax54; X86-FAST-NEXT: retl55;56; X86-SLOW-LABEL: var_shift_i16:57; X86-SLOW: # %bb.0:58; X86-SLOW-NEXT: movzbl {{[0-9]+}}(%esp), %ecx59; X86-SLOW-NEXT: movzwl {{[0-9]+}}(%esp), %edx60; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax61; X86-SLOW-NEXT: shll $16, %eax62; X86-SLOW-NEXT: orl %edx, %eax63; X86-SLOW-NEXT: andb $15, %cl64; X86-SLOW-NEXT: shll %cl, %eax65; X86-SLOW-NEXT: shrl $16, %eax66; X86-SLOW-NEXT: # kill: def $ax killed $ax killed $eax67; X86-SLOW-NEXT: retl68;69; X64-FAST-LABEL: var_shift_i16:70; X64-FAST: # %bb.0:71; X64-FAST-NEXT: movl %edx, %ecx72; X64-FAST-NEXT: movl %edi, %eax73; X64-FAST-NEXT: andb $15, %cl74; X64-FAST-NEXT: # kill: def $cl killed $cl killed $ecx75; X64-FAST-NEXT: shldw %cl, %si, %ax76; X64-FAST-NEXT: # kill: def $ax killed $ax killed $eax77; X64-FAST-NEXT: retq78;79; X64-SLOW-LABEL: var_shift_i16:80; X64-SLOW: # %bb.0:81; X64-SLOW-NEXT: movl %edx, %ecx82; X64-SLOW-NEXT: shll $16, %edi83; X64-SLOW-NEXT: movzwl %si, %eax84; X64-SLOW-NEXT: orl %edi, %eax85; X64-SLOW-NEXT: andb $15, %cl86; X64-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx87; X64-SLOW-NEXT: shll %cl, %eax88; X64-SLOW-NEXT: shrl $16, %eax89; X64-SLOW-NEXT: # kill: def $ax killed $ax killed $eax90; X64-SLOW-NEXT: retq91 %tmp = tail call i16 @llvm.fshl.i16(i16 %x, i16 %y, i16 %z)92 ret i16 %tmp93}94 95define i32 @var_shift_i32(i32 %x, i32 %y, i32 %z) nounwind {96; X86-FAST-LABEL: var_shift_i32:97; X86-FAST: # %bb.0:98; X86-FAST-NEXT: movzbl {{[0-9]+}}(%esp), %ecx99; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx100; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax101; X86-FAST-NEXT: shldl %cl, %edx, %eax102; X86-FAST-NEXT: retl103;104; X86-SLOW-LABEL: var_shift_i32:105; X86-SLOW: # %bb.0:106; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax107; X86-SLOW-NEXT: movzbl {{[0-9]+}}(%esp), %ecx108; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edx109; X86-SLOW-NEXT: shll %cl, %edx110; X86-SLOW-NEXT: notb %cl111; X86-SLOW-NEXT: shrl %eax112; X86-SLOW-NEXT: shrl %cl, %eax113; X86-SLOW-NEXT: orl %edx, %eax114; X86-SLOW-NEXT: retl115;116; X64-FAST-LABEL: var_shift_i32:117; X64-FAST: # %bb.0:118; X64-FAST-NEXT: movl %edx, %ecx119; X64-FAST-NEXT: movl %edi, %eax120; X64-FAST-NEXT: # kill: def $cl killed $cl killed $ecx121; X64-FAST-NEXT: shldl %cl, %esi, %eax122; X64-FAST-NEXT: retq123;124; X64-SLOW-LABEL: var_shift_i32:125; X64-SLOW: # %bb.0:126; X64-SLOW-NEXT: movl %edx, %ecx127; X64-SLOW-NEXT: movl %esi, %eax128; X64-SLOW-NEXT: shll %cl, %edi129; X64-SLOW-NEXT: shrl %eax130; X64-SLOW-NEXT: notb %cl131; X64-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx132; X64-SLOW-NEXT: shrl %cl, %eax133; X64-SLOW-NEXT: orl %edi, %eax134; X64-SLOW-NEXT: retq135 %tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 %z)136 ret i32 %tmp137}138 139define i32 @var_shift_i32_optsize(i32 %x, i32 %y, i32 %z) nounwind optsize {140; X86-LABEL: var_shift_i32_optsize:141; X86: # %bb.0:142; X86-NEXT: movb {{[0-9]+}}(%esp), %cl143; X86-NEXT: movl {{[0-9]+}}(%esp), %edx144; X86-NEXT: movl {{[0-9]+}}(%esp), %eax145; X86-NEXT: shldl %cl, %edx, %eax146; X86-NEXT: retl147;148; X64-LABEL: var_shift_i32_optsize:149; X64: # %bb.0:150; X64-NEXT: movl %edx, %ecx151; X64-NEXT: movl %edi, %eax152; X64-NEXT: # kill: def $cl killed $cl killed $ecx153; X64-NEXT: shldl %cl, %esi, %eax154; X64-NEXT: retq155 %tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 %z)156 ret i32 %tmp157}158 159define i32 @var_shift_i32_pgso(i32 %x, i32 %y, i32 %z) nounwind !prof !14 {160; X86-LABEL: var_shift_i32_pgso:161; X86: # %bb.0:162; X86-NEXT: movb {{[0-9]+}}(%esp), %cl163; X86-NEXT: movl {{[0-9]+}}(%esp), %edx164; X86-NEXT: movl {{[0-9]+}}(%esp), %eax165; X86-NEXT: shldl %cl, %edx, %eax166; X86-NEXT: retl167;168; X64-LABEL: var_shift_i32_pgso:169; X64: # %bb.0:170; X64-NEXT: movl %edx, %ecx171; X64-NEXT: movl %edi, %eax172; X64-NEXT: # kill: def $cl killed $cl killed $ecx173; X64-NEXT: shldl %cl, %esi, %eax174; X64-NEXT: retq175 %tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 %z)176 ret i32 %tmp177}178 179define i64 @var_shift_i64(i64 %x, i64 %y, i64 %z) nounwind {180; X86-FAST-LABEL: var_shift_i64:181; X86-FAST: # %bb.0:182; X86-FAST-NEXT: pushl %edi183; X86-FAST-NEXT: pushl %esi184; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %esi185; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx186; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %ecx187; X86-FAST-NEXT: testb $32, %cl188; X86-FAST-NEXT: jne .LBB5_1189; X86-FAST-NEXT: # %bb.2:190; X86-FAST-NEXT: movl %edx, %edi191; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx192; X86-FAST-NEXT: jmp .LBB5_3193; X86-FAST-NEXT: .LBB5_1:194; X86-FAST-NEXT: movl %esi, %edi195; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %esi196; X86-FAST-NEXT: .LBB5_3:197; X86-FAST-NEXT: movl %edi, %eax198; X86-FAST-NEXT: shldl %cl, %esi, %eax199; X86-FAST-NEXT: # kill: def $cl killed $cl killed $ecx200; X86-FAST-NEXT: shldl %cl, %edi, %edx201; X86-FAST-NEXT: popl %esi202; X86-FAST-NEXT: popl %edi203; X86-FAST-NEXT: retl204;205; X86-SLOW-LABEL: var_shift_i64:206; X86-SLOW: # %bb.0:207; X86-SLOW-NEXT: pushl %ebx208; X86-SLOW-NEXT: pushl %edi209; X86-SLOW-NEXT: pushl %esi210; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax211; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edx212; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ebx213; X86-SLOW-NEXT: testb $32, %bl214; X86-SLOW-NEXT: jne .LBB5_1215; X86-SLOW-NEXT: # %bb.2:216; X86-SLOW-NEXT: movl %edx, %esi217; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edx218; X86-SLOW-NEXT: jmp .LBB5_3219; X86-SLOW-NEXT: .LBB5_1:220; X86-SLOW-NEXT: movl %eax, %esi221; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax222; X86-SLOW-NEXT: .LBB5_3:223; X86-SLOW-NEXT: movl %esi, %edi224; X86-SLOW-NEXT: movl %ebx, %ecx225; X86-SLOW-NEXT: shll %cl, %edi226; X86-SLOW-NEXT: shrl %eax227; X86-SLOW-NEXT: notb %cl228; X86-SLOW-NEXT: shrl %cl, %eax229; X86-SLOW-NEXT: orl %edi, %eax230; X86-SLOW-NEXT: shrl %esi231; X86-SLOW-NEXT: shrl %cl, %esi232; X86-SLOW-NEXT: movl %ebx, %ecx233; X86-SLOW-NEXT: shll %cl, %edx234; X86-SLOW-NEXT: orl %esi, %edx235; X86-SLOW-NEXT: popl %esi236; X86-SLOW-NEXT: popl %edi237; X86-SLOW-NEXT: popl %ebx238; X86-SLOW-NEXT: retl239;240; X64-FAST-LABEL: var_shift_i64:241; X64-FAST: # %bb.0:242; X64-FAST-NEXT: movq %rdx, %rcx243; X64-FAST-NEXT: movq %rdi, %rax244; X64-FAST-NEXT: # kill: def $cl killed $cl killed $rcx245; X64-FAST-NEXT: shldq %cl, %rsi, %rax246; X64-FAST-NEXT: retq247;248; X64-SLOW-LABEL: var_shift_i64:249; X64-SLOW: # %bb.0:250; X64-SLOW-NEXT: movq %rdx, %rcx251; X64-SLOW-NEXT: movq %rsi, %rax252; X64-SLOW-NEXT: shlq %cl, %rdi253; X64-SLOW-NEXT: shrq %rax254; X64-SLOW-NEXT: notb %cl255; X64-SLOW-NEXT: # kill: def $cl killed $cl killed $rcx256; X64-SLOW-NEXT: shrq %cl, %rax257; X64-SLOW-NEXT: orq %rdi, %rax258; X64-SLOW-NEXT: retq259 %tmp = tail call i64 @llvm.fshl.i64(i64 %x, i64 %y, i64 %z)260 ret i64 %tmp261}262 263define i128 @var_shift_i128(i128 %x, i128 %y, i128 %z) nounwind {264; X86-FAST-LABEL: var_shift_i128:265; X86-FAST: # %bb.0:266; X86-FAST-NEXT: pushl %ebp267; X86-FAST-NEXT: movl %esp, %ebp268; X86-FAST-NEXT: pushl %ebx269; X86-FAST-NEXT: pushl %edi270; X86-FAST-NEXT: pushl %esi271; X86-FAST-NEXT: andl $-16, %esp272; X86-FAST-NEXT: subl $16, %esp273; X86-FAST-NEXT: movl 24(%ebp), %edi274; X86-FAST-NEXT: movl 28(%ebp), %edx275; X86-FAST-NEXT: movl 48(%ebp), %esi276; X86-FAST-NEXT: movl 56(%ebp), %ecx277; X86-FAST-NEXT: testb $64, %cl278; X86-FAST-NEXT: movl 52(%ebp), %eax279; X86-FAST-NEXT: jne .LBB6_1280; X86-FAST-NEXT: # %bb.2:281; X86-FAST-NEXT: movl %esi, %ebx282; X86-FAST-NEXT: movl %edi, %esi283; X86-FAST-NEXT: movl 32(%ebp), %edi284; X86-FAST-NEXT: movl %eax, (%esp) # 4-byte Spill285; X86-FAST-NEXT: movl %edx, %eax286; X86-FAST-NEXT: movl 36(%ebp), %edx287; X86-FAST-NEXT: testb $32, %cl288; X86-FAST-NEXT: je .LBB6_5289; X86-FAST-NEXT: .LBB6_4:290; X86-FAST-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill291; X86-FAST-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill292; X86-FAST-NEXT: movl %esi, %eax293; X86-FAST-NEXT: movl (%esp), %esi # 4-byte Reload294; X86-FAST-NEXT: jmp .LBB6_6295; X86-FAST-NEXT: .LBB6_1:296; X86-FAST-NEXT: movl 44(%ebp), %ebx297; X86-FAST-NEXT: movl %ebx, (%esp) # 4-byte Spill298; X86-FAST-NEXT: movl 40(%ebp), %ebx299; X86-FAST-NEXT: testb $32, %cl300; X86-FAST-NEXT: jne .LBB6_4301; X86-FAST-NEXT: .LBB6_5:302; X86-FAST-NEXT: movl (%esp), %ebx # 4-byte Reload303; X86-FAST-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill304; X86-FAST-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill305; X86-FAST-NEXT: .LBB6_6:306; X86-FAST-NEXT: movl %esi, %edi307; X86-FAST-NEXT: shldl %cl, %ebx, %edi308; X86-FAST-NEXT: movl %eax, %edx309; X86-FAST-NEXT: movl %eax, %ebx310; X86-FAST-NEXT: shldl %cl, %esi, %ebx311; X86-FAST-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload312; X86-FAST-NEXT: movl %eax, %esi313; X86-FAST-NEXT: shldl %cl, %edx, %esi314; X86-FAST-NEXT: # kill: def $cl killed $cl killed $ecx315; X86-FAST-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload316; X86-FAST-NEXT: shldl %cl, %eax, %edx317; X86-FAST-NEXT: movl 8(%ebp), %eax318; X86-FAST-NEXT: movl %edx, 12(%eax)319; X86-FAST-NEXT: movl %esi, 8(%eax)320; X86-FAST-NEXT: movl %ebx, 4(%eax)321; X86-FAST-NEXT: movl %edi, (%eax)322; X86-FAST-NEXT: leal -12(%ebp), %esp323; X86-FAST-NEXT: popl %esi324; X86-FAST-NEXT: popl %edi325; X86-FAST-NEXT: popl %ebx326; X86-FAST-NEXT: popl %ebp327; X86-FAST-NEXT: retl $4328;329; X86-SLOW-LABEL: var_shift_i128:330; X86-SLOW: # %bb.0:331; X86-SLOW-NEXT: pushl %ebp332; X86-SLOW-NEXT: movl %esp, %ebp333; X86-SLOW-NEXT: pushl %ebx334; X86-SLOW-NEXT: pushl %edi335; X86-SLOW-NEXT: pushl %esi336; X86-SLOW-NEXT: andl $-16, %esp337; X86-SLOW-NEXT: subl $32, %esp338; X86-SLOW-NEXT: movl 24(%ebp), %edi339; X86-SLOW-NEXT: movl 28(%ebp), %eax340; X86-SLOW-NEXT: movl 48(%ebp), %edx341; X86-SLOW-NEXT: movl 56(%ebp), %ecx342; X86-SLOW-NEXT: testb $64, %cl343; X86-SLOW-NEXT: movl 52(%ebp), %ebx344; X86-SLOW-NEXT: jne .LBB6_1345; X86-SLOW-NEXT: # %bb.2:346; X86-SLOW-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill347; X86-SLOW-NEXT: movl %edi, %edx348; X86-SLOW-NEXT: movl 32(%ebp), %edi349; X86-SLOW-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill350; X86-SLOW-NEXT: movl %eax, %ebx351; X86-SLOW-NEXT: movl 36(%ebp), %eax352; X86-SLOW-NEXT: jmp .LBB6_3353; X86-SLOW-NEXT: .LBB6_1:354; X86-SLOW-NEXT: movl 40(%ebp), %ecx355; X86-SLOW-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill356; X86-SLOW-NEXT: movl 44(%ebp), %ecx357; X86-SLOW-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill358; X86-SLOW-NEXT: .LBB6_3:359; X86-SLOW-NEXT: movl 56(%ebp), %ecx360; X86-SLOW-NEXT: testb $32, %cl361; X86-SLOW-NEXT: jne .LBB6_4362; X86-SLOW-NEXT: # %bb.5:363; X86-SLOW-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill364; X86-SLOW-NEXT: movl %edx, %edi365; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload366; X86-SLOW-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill367; X86-SLOW-NEXT: jmp .LBB6_6368; X86-SLOW-NEXT: .LBB6_4:369; X86-SLOW-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill370; X86-SLOW-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill371; X86-SLOW-NEXT: movl %edx, %ebx372; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload373; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload374; X86-SLOW-NEXT: .LBB6_6:375; X86-SLOW-NEXT: movl %edi, %eax376; X86-SLOW-NEXT: shll %cl, %eax377; X86-SLOW-NEXT: shrl %esi378; X86-SLOW-NEXT: movl %ecx, %edx379; X86-SLOW-NEXT: notb %dl380; X86-SLOW-NEXT: movl %edx, %ecx381; X86-SLOW-NEXT: shrl %cl, %esi382; X86-SLOW-NEXT: orl %eax, %esi383; X86-SLOW-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill384; X86-SLOW-NEXT: movl %ebx, %eax385; X86-SLOW-NEXT: movl 56(%ebp), %ecx386; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx387; X86-SLOW-NEXT: shll %cl, %eax388; X86-SLOW-NEXT: shrl %edi389; X86-SLOW-NEXT: movl %edx, %ecx390; X86-SLOW-NEXT: shrl %cl, %edi391; X86-SLOW-NEXT: orl %eax, %edi392; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload393; X86-SLOW-NEXT: movl %esi, %eax394; X86-SLOW-NEXT: movl 56(%ebp), %ecx395; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx396; X86-SLOW-NEXT: shll %cl, %eax397; X86-SLOW-NEXT: shrl %ebx398; X86-SLOW-NEXT: movl %edx, %ecx399; X86-SLOW-NEXT: shrl %cl, %ebx400; X86-SLOW-NEXT: orl %eax, %ebx401; X86-SLOW-NEXT: movl 56(%ebp), %ecx402; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx403; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload404; X86-SLOW-NEXT: shll %cl, %eax405; X86-SLOW-NEXT: shrl %esi406; X86-SLOW-NEXT: movl %edx, %ecx407; X86-SLOW-NEXT: shrl %cl, %esi408; X86-SLOW-NEXT: orl %eax, %esi409; X86-SLOW-NEXT: movl 8(%ebp), %eax410; X86-SLOW-NEXT: movl %esi, 12(%eax)411; X86-SLOW-NEXT: movl %ebx, 8(%eax)412; X86-SLOW-NEXT: movl %edi, 4(%eax)413; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload414; X86-SLOW-NEXT: movl %ecx, (%eax)415; X86-SLOW-NEXT: leal -12(%ebp), %esp416; X86-SLOW-NEXT: popl %esi417; X86-SLOW-NEXT: popl %edi418; X86-SLOW-NEXT: popl %ebx419; X86-SLOW-NEXT: popl %ebp420; X86-SLOW-NEXT: retl $4421;422; X64-FAST-LABEL: var_shift_i128:423; X64-FAST: # %bb.0:424; X64-FAST-NEXT: testb $64, %r8b425; X64-FAST-NEXT: cmovneq %rdi, %rsi426; X64-FAST-NEXT: cmoveq %rcx, %rdx427; X64-FAST-NEXT: cmovneq %rcx, %rdi428; X64-FAST-NEXT: movq %rdi, %rax429; X64-FAST-NEXT: movl %r8d, %ecx430; X64-FAST-NEXT: shldq %cl, %rdx, %rax431; X64-FAST-NEXT: shldq %cl, %rdi, %rsi432; X64-FAST-NEXT: movq %rsi, %rdx433; X64-FAST-NEXT: retq434;435; X64-SLOW-LABEL: var_shift_i128:436; X64-SLOW: # %bb.0:437; X64-SLOW-NEXT: testb $64, %r8b438; X64-SLOW-NEXT: cmovneq %rdi, %rsi439; X64-SLOW-NEXT: cmoveq %rcx, %rdx440; X64-SLOW-NEXT: cmovneq %rcx, %rdi441; X64-SLOW-NEXT: movq %rdi, %rax442; X64-SLOW-NEXT: movl %r8d, %ecx443; X64-SLOW-NEXT: shlq %cl, %rax444; X64-SLOW-NEXT: shrq %rdx445; X64-SLOW-NEXT: movl %r8d, %r9d446; X64-SLOW-NEXT: notb %r9b447; X64-SLOW-NEXT: movl %r9d, %ecx448; X64-SLOW-NEXT: shrq %cl, %rdx449; X64-SLOW-NEXT: orq %rdx, %rax450; X64-SLOW-NEXT: movl %r8d, %ecx451; X64-SLOW-NEXT: shlq %cl, %rsi452; X64-SLOW-NEXT: shrq %rdi453; X64-SLOW-NEXT: movl %r9d, %ecx454; X64-SLOW-NEXT: shrq %cl, %rdi455; X64-SLOW-NEXT: orq %rsi, %rdi456; X64-SLOW-NEXT: movq %rdi, %rdx457; X64-SLOW-NEXT: retq458 %tmp = tail call i128 @llvm.fshl.i128(i128 %x, i128 %y, i128 %z)459 ret i128 %tmp460}461 462;463; Const Funnel Shift464;465 466define i8 @const_shift_i8(i8 %x, i8 %y) nounwind {467; X86-LABEL: const_shift_i8:468; X86: # %bb.0:469; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax470; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx471; X86-NEXT: shrb %cl472; X86-NEXT: shlb $7, %al473; X86-NEXT: orb %cl, %al474; X86-NEXT: retl475;476; X64-LABEL: const_shift_i8:477; X64: # %bb.0:478; X64-NEXT: # kill: def $esi killed $esi def $rsi479; X64-NEXT: # kill: def $edi killed $edi def $rdi480; X64-NEXT: shrb %sil481; X64-NEXT: shlb $7, %dil482; X64-NEXT: leal (%rdi,%rsi), %eax483; X64-NEXT: # kill: def $al killed $al killed $eax484; X64-NEXT: retq485 %tmp = tail call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 7)486 ret i8 %tmp487}488 489define i16 @const_shift_i16(i16 %x, i16 %y) nounwind {490; X86-FAST-LABEL: const_shift_i16:491; X86-FAST: # %bb.0:492; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %ecx493; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %eax494; X86-FAST-NEXT: shldw $7, %cx, %ax495; X86-FAST-NEXT: retl496;497; X86-SLOW-LABEL: const_shift_i16:498; X86-SLOW: # %bb.0:499; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax500; X86-SLOW-NEXT: movzwl {{[0-9]+}}(%esp), %ecx501; X86-SLOW-NEXT: shrl $9, %ecx502; X86-SLOW-NEXT: shll $7, %eax503; X86-SLOW-NEXT: orl %ecx, %eax504; X86-SLOW-NEXT: # kill: def $ax killed $ax killed $eax505; X86-SLOW-NEXT: retl506;507; X64-FAST-LABEL: const_shift_i16:508; X64-FAST: # %bb.0:509; X64-FAST-NEXT: movl %edi, %eax510; X64-FAST-NEXT: shldw $7, %si, %ax511; X64-FAST-NEXT: # kill: def $ax killed $ax killed $eax512; X64-FAST-NEXT: retq513;514; X64-SLOW-LABEL: const_shift_i16:515; X64-SLOW: # %bb.0:516; X64-SLOW-NEXT: movzwl %si, %eax517; X64-SLOW-NEXT: shll $7, %edi518; X64-SLOW-NEXT: shrl $9, %eax519; X64-SLOW-NEXT: orl %edi, %eax520; X64-SLOW-NEXT: # kill: def $ax killed $ax killed $eax521; X64-SLOW-NEXT: retq522 %tmp = tail call i16 @llvm.fshl.i16(i16 %x, i16 %y, i16 7)523 ret i16 %tmp524}525 526define i32 @const_shift_i32(i32 %x, i32 %y) nounwind {527; X86-FAST-LABEL: const_shift_i32:528; X86-FAST: # %bb.0:529; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %ecx530; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax531; X86-FAST-NEXT: shldl $7, %ecx, %eax532; X86-FAST-NEXT: retl533;534; X86-SLOW-LABEL: const_shift_i32:535; X86-SLOW: # %bb.0:536; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax537; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ecx538; X86-SLOW-NEXT: shrl $25, %ecx539; X86-SLOW-NEXT: shll $7, %eax540; X86-SLOW-NEXT: orl %ecx, %eax541; X86-SLOW-NEXT: retl542;543; X64-FAST-LABEL: const_shift_i32:544; X64-FAST: # %bb.0:545; X64-FAST-NEXT: movl %edi, %eax546; X64-FAST-NEXT: shldl $7, %esi, %eax547; X64-FAST-NEXT: retq548;549; X64-SLOW-LABEL: const_shift_i32:550; X64-SLOW: # %bb.0:551; X64-SLOW-NEXT: # kill: def $esi killed $esi def $rsi552; X64-SLOW-NEXT: # kill: def $edi killed $edi def $rdi553; X64-SLOW-NEXT: shrl $25, %esi554; X64-SLOW-NEXT: shll $7, %edi555; X64-SLOW-NEXT: leal (%rdi,%rsi), %eax556; X64-SLOW-NEXT: retq557 %tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 7)558 ret i32 %tmp559}560 561define i64 @const_shift_i64(i64 %x, i64 %y) nounwind {562; X86-FAST-LABEL: const_shift_i64:563; X86-FAST: # %bb.0:564; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax565; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %ecx566; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx567; X86-FAST-NEXT: shrdl $25, %ecx, %eax568; X86-FAST-NEXT: shldl $7, %ecx, %edx569; X86-FAST-NEXT: retl570;571; X86-SLOW-LABEL: const_shift_i64:572; X86-SLOW: # %bb.0:573; X86-SLOW-NEXT: pushl %esi574; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ecx575; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edx576; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %esi577; X86-SLOW-NEXT: shrl $25, %esi578; X86-SLOW-NEXT: movl %ecx, %eax579; X86-SLOW-NEXT: shll $7, %eax580; X86-SLOW-NEXT: orl %esi, %eax581; X86-SLOW-NEXT: shrl $25, %ecx582; X86-SLOW-NEXT: shll $7, %edx583; X86-SLOW-NEXT: orl %ecx, %edx584; X86-SLOW-NEXT: popl %esi585; X86-SLOW-NEXT: retl586;587; X64-FAST-LABEL: const_shift_i64:588; X64-FAST: # %bb.0:589; X64-FAST-NEXT: movq %rdi, %rax590; X64-FAST-NEXT: shldq $7, %rsi, %rax591; X64-FAST-NEXT: retq592;593; X64-SLOW-LABEL: const_shift_i64:594; X64-SLOW: # %bb.0:595; X64-SLOW-NEXT: shrq $57, %rsi596; X64-SLOW-NEXT: shlq $7, %rdi597; X64-SLOW-NEXT: leaq (%rdi,%rsi), %rax598; X64-SLOW-NEXT: retq599 %tmp = tail call i64 @llvm.fshl.i64(i64 %x, i64 %y, i64 7)600 ret i64 %tmp601}602 603;604; Combine Consecutive Loads605;606 607define i8 @combine_fshl_load_i8(ptr %p) nounwind {608; X86-LABEL: combine_fshl_load_i8:609; X86: # %bb.0:610; X86-NEXT: movl {{[0-9]+}}(%esp), %eax611; X86-NEXT: movzbl 1(%eax), %eax612; X86-NEXT: retl613;614; X64-LABEL: combine_fshl_load_i8:615; X64: # %bb.0:616; X64-NEXT: movzbl 1(%rdi), %eax617; X64-NEXT: retq618 %p1 = getelementptr i8, ptr %p, i32 1619 %ld0 = load i8, ptr%p620 %ld1 = load i8, ptr%p1621 %res = call i8 @llvm.fshl.i8(i8 %ld1, i8 %ld0, i8 8)622 ret i8 %res623}624 625define i16 @combine_fshl_load_i16(ptr %p) nounwind {626; X86-LABEL: combine_fshl_load_i16:627; X86: # %bb.0:628; X86-NEXT: movl {{[0-9]+}}(%esp), %eax629; X86-NEXT: movzwl 1(%eax), %eax630; X86-NEXT: retl631;632; X64-LABEL: combine_fshl_load_i16:633; X64: # %bb.0:634; X64-NEXT: movzwl 1(%rdi), %eax635; X64-NEXT: retq636 %p1 = getelementptr i16, ptr %p, i32 1637 %ld0 = load i16, ptr%p638 %ld1 = load i16, ptr%p1639 %res = call i16 @llvm.fshl.i16(i16 %ld1, i16 %ld0, i16 8)640 ret i16 %res641}642 643define i32 @combine_fshl_load_i32(ptr %p) nounwind {644; X86-LABEL: combine_fshl_load_i32:645; X86: # %bb.0:646; X86-NEXT: movl {{[0-9]+}}(%esp), %eax647; X86-NEXT: movl 11(%eax), %eax648; X86-NEXT: retl649;650; X64-LABEL: combine_fshl_load_i32:651; X64: # %bb.0:652; X64-NEXT: movl 11(%rdi), %eax653; X64-NEXT: retq654 %p0 = getelementptr i32, ptr %p, i32 2655 %p1 = getelementptr i32, ptr %p, i32 3656 %ld0 = load i32, ptr%p0657 %ld1 = load i32, ptr%p1658 %res = call i32 @llvm.fshl.i32(i32 %ld1, i32 %ld0, i32 8)659 ret i32 %res660}661 662define i64 @combine_fshl_load_i64(ptr %p) nounwind {663; X86-LABEL: combine_fshl_load_i64:664; X86: # %bb.0:665; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx666; X86-NEXT: movl 13(%ecx), %eax667; X86-NEXT: movl 17(%ecx), %edx668; X86-NEXT: retl669;670; X64-LABEL: combine_fshl_load_i64:671; X64: # %bb.0:672; X64-NEXT: movq 13(%rdi), %rax673; X64-NEXT: retq674 %p0 = getelementptr i64, ptr %p, i64 1675 %p1 = getelementptr i64, ptr %p, i64 2676 %ld0 = load i64, ptr%p0677 %ld1 = load i64, ptr%p1678 %res = call i64 @llvm.fshl.i64(i64 %ld1, i64 %ld0, i64 24)679 ret i64 %res680}681 682define i16 @combine_fshl_load_i16_chain_use(ptr %p, ptr %q, i16 %r) nounwind {683; X86-LABEL: combine_fshl_load_i16_chain_use:684; X86: # %bb.0:685; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx686; X86-NEXT: movl {{[0-9]+}}(%esp), %edx687; X86-NEXT: movl {{[0-9]+}}(%esp), %eax688; X86-NEXT: movzwl 1(%eax), %eax689; X86-NEXT: movw %cx, (%edx)690; X86-NEXT: retl691;692; X64-LABEL: combine_fshl_load_i16_chain_use:693; X64: # %bb.0:694; X64-NEXT: movzwl 1(%rdi), %eax695; X64-NEXT: movw %dx, (%rsi)696; X64-NEXT: retq697 %p1 = getelementptr i16, ptr %p, i32 1698 %ld0 = load i16, ptr %p699 %ld1 = load i16, ptr %p1700 %res = call i16 @llvm.fshl.i16(i16 %ld1, i16 %ld0, i16 8)701 store i16 %r, ptr %q702 ret i16 %res703}704 705!llvm.module.flags = !{!0}706!0 = !{i32 1, !"ProfileSummary", !1}707!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}708!2 = !{!"ProfileFormat", !"InstrProf"}709!3 = !{!"TotalCount", i64 10000}710!4 = !{!"MaxCount", i64 10}711!5 = !{!"MaxInternalCount", i64 1}712!6 = !{!"MaxFunctionCount", i64 1000}713!7 = !{!"NumCounts", i64 3}714!8 = !{!"NumFunctions", i64 3}715!9 = !{!"DetailedSummary", !10}716!10 = !{!11, !12, !13}717!11 = !{i32 10000, i64 100, i32 1}718!12 = !{i32 999000, i64 100, i32 1}719!13 = !{i32 999999, i64 1, i32 2}720!14 = !{!"function_entry_count", i64 0}721