Index: lib/Target/X86/X86InstrCompiler.td =================================================================== --- lib/Target/X86/X86InstrCompiler.td +++ lib/Target/X86/X86InstrCompiler.td @@ -861,7 +861,7 @@ !strconcat(mnemonic, "{l}\t{$val, $ptr|$ptr, $val}"), [(set GR32:$dst, - (!cast(frag # "_32") addr:$ptr, GR32:$val))]>, + (!cast(frag # "_32") addr:$ptr, GR32:$val))]>, OpSize32; def NAME#64 : RI; } // HasBMI, NoTBM + +multiclass _bmi_pattern { + def : Pat; + def : Pat; +} + +multiclass _bmi_patterns { + // x & ((1 << y) - 1) + defm : _bmi_pattern<(and RC:$src, (add (shl 1, GR8:$lz), -1)), + (and (x86memop addr:$src), (add (shl 1, GR8:$lz), -1)), + RC, DstInst, DstMemInst, Control8bit>; + + // x & ~(-1 << y) + defm : _bmi_pattern<(and RC:$src, (xor (shl -1, GR8:$lz), -1)), + (and (x86memop addr:$src), (xor (shl -1, GR8:$lz), -1)), + RC, DstInst, DstMemInst, Control8bit>; + + // x & (-1 >> (bitwidth - y)) + defm : _bmi_pattern<(and RC:$src, (srl -1, (sub bitwidth, GR8:$lz))), + (and (x86memop addr:$src), + (srl -1, (sub bitwidth, GR8:$lz))), + RC, DstInst, DstMemInst, Control8bit>; + + // x << (bitwidth - y) >> (bitwidth - y) + defm : _bmi_pattern<(srl (shl RC:$src, (sub bitwidth, GR8:$lz)), + (sub bitwidth, GR8:$lz)), + (srl (shl (x86memop addr:$src), + (sub bitwidth, GR8:$lz)), + (sub bitwidth, GR8:$lz)), + RC, DstInst, DstMemInst, Control8bit>; +} + +multiclass _bmi_bit_extraction_pattern< + Instruction Dst32Inst, Instruction DstMem32Inst, + Instruction Dst64Inst, Instruction DstMem64Inst, + dag Control8bit_32, dag Control8bit_64, + dag Control32bit, dag Control64bit> { + defm : _bmi_patterns; + defm : _bmi_patterns; + + // x & (-1 >> (32 - y)) + def : Pat<(and GR32:$src, (srl -1, (i8 (trunc (sub 32, GR32:$lz))))), + (Dst32Inst GR32:$src, Control32bit)>; + def : Pat<(and (loadi32 addr:$src), (srl -1, (i8 (trunc (sub 32, GR32:$lz))))), + (DstMem32Inst addr:$src, Control32bit)>; + + // x & (-1 >> (64 - y)) + def : Pat<(and GR64:$src, (srl -1, (i8 (trunc (sub 64, GR32:$lz))))), + (Dst64Inst GR64:$src, Control64bit)>; + def : Pat<(and (loadi64 addr:$src), (srl -1, (i8 (trunc (sub 64, GR32:$lz))))), + (DstMem64Inst addr:$src, Control64bit)>; + + // x << (32 - y) >> (32 - y) + def : Pat<(srl (shl GR32:$src, (i8 (trunc (sub 32, GR32:$lz)))), + (i8 (trunc (sub 32, GR32:$lz)))), + (Dst32Inst GR32:$src, Control32bit)>; + def : Pat<(srl (shl (loadi32 addr:$src), (i8 (trunc (sub 32, GR32:$lz)))), + (i8 (trunc (sub 32, GR32:$lz)))), + (DstMem32Inst addr:$src, Control32bit)>; + + // x << (64 - y) >> (64 - y) + def : Pat<(srl (shl GR64:$src, (i8 (trunc (sub 64, GR32:$lz)))), + (i8 (trunc (sub 64, GR32:$lz)))), + (Dst64Inst GR64:$src, Control64bit)>; + def : Pat<(srl (shl (loadi64 addr:$src), (i8 (trunc (sub 64, GR32:$lz)))), + (i8 (trunc (sub 64, GR32:$lz)))), + (DstMem64Inst addr:$src, Control64bit)>; +} + +let Predicates = [HasBMI, NoBMI2] in { + defm : _bmi_bit_extraction_pattern; +} + +let Predicates = [HasBMI2] in { + defm : _bmi_bit_extraction_pattern; +} Index: lib/Target/X86/X86InstrInfo.td =================================================================== --- lib/Target/X86/X86InstrInfo.td +++ lib/Target/X86/X86InstrInfo.td @@ -2485,84 +2485,6 @@ (MOV8ri (CountTrailingOnes imm:$mask)), sub_8bit))>; } -let Predicates = [HasBMI2] in { - multiclass _bmi_bzhi_pattern { - def : Pat; - def : Pat; - } - - multiclass bmi_bzhi_patterns { - // x & ((1 << y) - 1) - defm : _bmi_bzhi_pattern<(and RC:$src, (add (shl 1, GR8:$lz), -1)), - (and (x86memop addr:$src), - (add (shl 1, GR8:$lz), -1)), - RC, VT, DstInst, DstMemInst>; - - // x & ~(-1 << y) - defm : _bmi_bzhi_pattern<(and RC:$src, (xor (shl -1, GR8:$lz), -1)), - (and (x86memop addr:$src), - (xor (shl -1, GR8:$lz), -1)), - RC, VT, DstInst, DstMemInst>; - - // x & (-1 >> (bitwidth - y)) - defm : _bmi_bzhi_pattern<(and RC:$src, (srl -1, (sub bitwidth, GR8:$lz))), - (and (x86memop addr:$src), - (srl -1, (sub bitwidth, GR8:$lz))), - RC, VT, DstInst, DstMemInst>; - - // x << (bitwidth - y) >> (bitwidth - y) - defm : _bmi_bzhi_pattern<(srl (shl RC:$src, (sub bitwidth, GR8:$lz)), - (sub bitwidth, GR8:$lz)), - (srl (shl (x86memop addr:$src), - (sub bitwidth, GR8:$lz)), - (sub bitwidth, GR8:$lz)), - RC, VT, DstInst, DstMemInst>; - } - - defm : bmi_bzhi_patterns; - defm : bmi_bzhi_patterns; - - // x & (-1 >> (32 - y)) - def : Pat<(and GR32:$src, (srl -1, (i8 (trunc (sub 32, GR32:$lz))))), - (BZHI32rr GR32:$src, GR32:$lz)>; - def : Pat<(and (loadi32 addr:$src), (srl -1, (i8 (trunc (sub 32, GR32:$lz))))), - (BZHI32rm addr:$src, GR32:$lz)>; - - // x & (-1 >> (64 - y)) - def : Pat<(and GR64:$src, (srl -1, (i8 (trunc (sub 64, GR32:$lz))))), - (BZHI64rr GR64:$src, - (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$lz, sub_32bit))>; - def : Pat<(and (loadi64 addr:$src), (srl -1, (i8 (trunc (sub 64, GR32:$lz))))), - (BZHI64rm addr:$src, - (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$lz, sub_32bit))>; - - // x << (32 - y) >> (32 - y) - def : Pat<(srl (shl GR32:$src, (i8 (trunc (sub 32, GR32:$lz)))), - (i8 (trunc (sub 32, GR32:$lz)))), - (BZHI32rr GR32:$src, GR32:$lz)>; - def : Pat<(srl (shl (loadi32 addr:$src), (i8 (trunc (sub 32, GR32:$lz)))), - (i8 (trunc (sub 32, GR32:$lz)))), - (BZHI32rm addr:$src, GR32:$lz)>; - - // x << (64 - y) >> (64 - y) - def : Pat<(srl (shl GR64:$src, (i8 (trunc (sub 64, GR32:$lz)))), - (i8 (trunc (sub 64, GR32:$lz)))), - (BZHI64rr GR64:$src, - (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$lz, sub_32bit))>; - def : Pat<(srl (shl (loadi64 addr:$src), (i8 (trunc (sub 64, GR32:$lz)))), - (i8 (trunc (sub 64, GR32:$lz)))), - (BZHI64rm addr:$src, - (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$lz, sub_32bit))>; -} // HasBMI2 - multiclass bmi_pdep_pext { Index: test/CodeGen/X86/extract-bits.ll =================================================================== --- test/CodeGen/X86/extract-bits.ll +++ test/CodeGen/X86/extract-bits.ll @@ -48,17 +48,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_a0: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %dl +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %esi -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: movl %edx, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_a0: @@ -84,11 +79,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_a0: @@ -121,17 +113,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_a1_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %dl +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %esi -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: movl %edx, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_a1_indexzext: @@ -157,11 +144,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_a1_indexzext: @@ -197,18 +181,13 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_a2_load: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %dl +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl (%eax), %esi -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: movl %edx, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl (%edx), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_a2_load: @@ -234,14 +213,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr32_a2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl (%rdi), %edi +; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shrl %cl, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %eax, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_a2_load: @@ -276,18 +252,13 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_a3_load_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %dl +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl (%eax), %esi -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: movl %edx, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl (%edx), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_a3_load_indexzext: @@ -313,14 +284,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr32_a3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl (%rdi), %edi +; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shrl %cl, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %eax, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_a3_load_indexzext: @@ -356,17 +324,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_a4_commutative: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %dl +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %esi -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: movl %edx, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_a4_commutative: @@ -392,11 +355,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_a4_commutative: @@ -437,25 +397,19 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_a5_skipextrauses: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %edi ; X86-BMI1NOTBM-NEXT: pushl %esi -; X86-BMI1NOTBM-NEXT: pushl %eax -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %dl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edi -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %edi -; X86-BMI1NOTBM-NEXT: movl $1, %esi -; X86-BMI1NOTBM-NEXT: movl %edx, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %esi -; X86-BMI1NOTBM-NEXT: decl %esi -; X86-BMI1NOTBM-NEXT: andl %edi, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, (%esp) +; X86-BMI1NOTBM-NEXT: subl $8, %esp +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %ecx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %esi +; X86-BMI1NOTBM-NEXT: movl %ecx, (%esp) ; X86-BMI1NOTBM-NEXT: calll use32 ; X86-BMI1NOTBM-NEXT: movl %esi, %eax -; X86-BMI1NOTBM-NEXT: addl $4, %esp +; X86-BMI1NOTBM-NEXT: addl $8, %esp ; X86-BMI1NOTBM-NEXT: popl %esi -; X86-BMI1NOTBM-NEXT: popl %edi ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_a5_skipextrauses: @@ -494,11 +448,8 @@ ; X64-BMI1NOTBM-NEXT: pushq %rbx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $1, %ebx -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %ebx -; X64-BMI1NOTBM-NEXT: decl %ebx -; X64-BMI1NOTBM-NEXT: andl %edi, %ebx +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %ebx ; X64-BMI1NOTBM-NEXT: movl %esi, %edi ; X64-BMI1NOTBM-NEXT: callq use32 ; X64-BMI1NOTBM-NEXT: movl %ebx, %eax @@ -650,11 +601,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_a0: @@ -792,13 +740,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_a1_indexzext: ; X64-BMI1NOTBM: # %bb.0: +; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_a1_indexzext: @@ -944,14 +890,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_a2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq (%rdi), %rdi +; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shrq %cl, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rax, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_a2_load: @@ -1094,14 +1037,12 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_a3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq (%rdi), %rdi +; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx +; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shrq %cl, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rax, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_a3_load_indexzext: @@ -1246,11 +1187,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_a4_commutative: @@ -1436,11 +1374,8 @@ ; X64-BMI1NOTBM-NEXT: pushq %rbx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $1, %ebx -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rbx -; X64-BMI1NOTBM-NEXT: decq %rbx -; X64-BMI1NOTBM-NEXT: andq %rdi, %rbx +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rbx ; X64-BMI1NOTBM-NEXT: movq %rsi, %rdi ; X64-BMI1NOTBM-NEXT: callq use64 ; X64-BMI1NOTBM-NEXT: movq %rbx, %rax @@ -1487,16 +1422,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_b0: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $-1, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %esi -; X86-BMI1NOTBM-NEXT: andnl %edx, %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_b0: @@ -1522,10 +1453,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl %edi, %eax, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_b0: @@ -1558,16 +1487,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_b1_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $-1, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %esi -; X86-BMI1NOTBM-NEXT: andnl %edx, %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_b1_indexzext: @@ -1593,10 +1518,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl %edi, %eax, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_b1_indexzext: @@ -1632,17 +1555,13 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_b2_load: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: movl (%edx), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $-1, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %esi -; X86-BMI1NOTBM-NEXT: andnl %edx, %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_b2_load: @@ -1671,10 +1590,8 @@ ; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: movl $-1, %esi -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %esi -; X64-BMI1NOTBM-NEXT: andnl %eax, %esi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %eax, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_b2_load: @@ -1709,17 +1626,13 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_b3_load_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: movl (%edx), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $-1, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %esi -; X86-BMI1NOTBM-NEXT: andnl %edx, %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_b3_load_indexzext: @@ -1748,10 +1661,8 @@ ; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: movl $-1, %esi -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %esi -; X64-BMI1NOTBM-NEXT: andnl %eax, %esi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %eax, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_b3_load_indexzext: @@ -1787,16 +1698,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_b4_commutative: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %esi ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $-1, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %esi -; X86-BMI1NOTBM-NEXT: andnl %edx, %esi, %eax -; X86-BMI1NOTBM-NEXT: popl %esi +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_b4_commutative: @@ -1822,10 +1729,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl %edi, %eax, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_b4_commutative: @@ -1866,24 +1771,19 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_b5_skipextrauses: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: pushl %edi ; X86-BMI1NOTBM-NEXT: pushl %esi -; X86-BMI1NOTBM-NEXT: pushl %eax -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %dl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %esi -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: movl $-1, %edi -; X86-BMI1NOTBM-NEXT: movl %edx, %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %edi -; X86-BMI1NOTBM-NEXT: andnl %esi, %edi, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, (%esp) +; X86-BMI1NOTBM-NEXT: subl $8, %esp +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %ecx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %esi +; X86-BMI1NOTBM-NEXT: movl %ecx, (%esp) ; X86-BMI1NOTBM-NEXT: calll use32 ; X86-BMI1NOTBM-NEXT: movl %esi, %eax -; X86-BMI1NOTBM-NEXT: addl $4, %esp +; X86-BMI1NOTBM-NEXT: addl $8, %esp ; X86-BMI1NOTBM-NEXT: popl %esi -; X86-BMI1NOTBM-NEXT: popl %edi ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_b5_skipextrauses: @@ -1922,10 +1822,8 @@ ; X64-BMI1NOTBM-NEXT: pushq %rbx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl %edi, %eax, %ebx +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %ebx ; X64-BMI1NOTBM-NEXT: movl %esi, %edi ; X64-BMI1NOTBM-NEXT: callq use32 ; X64-BMI1NOTBM-NEXT: movl %ebx, %eax @@ -2074,10 +1972,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq %rdi, %rax, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_b0: @@ -2212,12 +2108,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_b1_indexzext: ; X64-BMI1NOTBM: # %bb.0: +; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq %rdi, %rax, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_b1_indexzext: @@ -2363,10 +2258,8 @@ ; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: movq $-1, %rsi -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rsi -; X64-BMI1NOTBM-NEXT: andnq %rax, %rsi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rax, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_b2_load: @@ -2506,13 +2399,12 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_b3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: +; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx ; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: movq $-1, %rsi -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rsi -; X64-BMI1NOTBM-NEXT: andnq %rax, %rsi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rax, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_b3_load_indexzext: @@ -2654,10 +2546,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq %rdi, %rax, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_b4_commutative: @@ -2838,10 +2728,8 @@ ; X64-BMI1NOTBM-NEXT: pushq %rbx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq %rdi, %rax, %rbx +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rbx ; X64-BMI1NOTBM-NEXT: movq %rsi, %rdi ; X64-BMI1NOTBM-NEXT: callq use64 ; X64-BMI1NOTBM-NEXT: movq %rbx, %rax @@ -2886,15 +2774,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_c0: ; X86-BMI1NOTBM: # %bb.0: +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl %edx, %eax +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_c0: @@ -2902,6 +2787,7 @@ ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1BMI2-NEXT: shrxl %ecx, {{[0-9]+}}(%esp), %ecx +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, %ecx, %eax ; X86-BMI1BMI2-NEXT: retl ; @@ -2921,17 +2807,14 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_c0: ; X64-BMI1BMI2: # %bb.0: ; X64-BMI1BMI2-NEXT: shrxl %esi, %edi, %eax +; X64-BMI1BMI2-NEXT: shll $0, %edx ; X64-BMI1BMI2-NEXT: bzhil %edx, %eax, %eax ; X64-BMI1BMI2-NEXT: retq %shifted = lshr i32 %val, %numskipbits @@ -2956,14 +2839,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_c1_indexzext: ; X86-BMI1NOTBM: # %bb.0: +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movb $32, %cl -; X86-BMI1NOTBM-NEXT: subb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl %edx, %eax +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_c1_indexzext: @@ -2989,11 +2870,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movb $32, %cl -; X64-BMI1NOTBM-NEXT: subb %dl, %cl -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_c1_indexzext: @@ -3027,16 +2905,13 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_c2_load: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl (%eax), %edx +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl (%edx), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl %edx, %eax +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_c2_load: @@ -3045,6 +2920,7 @@ ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx ; X86-BMI1BMI2-NEXT: movb {{[0-9]+}}(%esp), %dl ; X86-BMI1BMI2-NEXT: shrxl %edx, (%ecx), %ecx +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, %ecx, %eax ; X86-BMI1BMI2-NEXT: retl ; @@ -3063,20 +2939,17 @@ ; ; X64-BMI1NOTBM-LABEL: bextr32_c2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl (%rdi), %edi +; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %eax, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_c2_load: ; X64-BMI1BMI2: # %bb.0: ; X64-BMI1BMI2-NEXT: shrxl %esi, (%rdi), %eax +; X64-BMI1BMI2-NEXT: shll $0, %edx ; X64-BMI1BMI2-NEXT: bzhil %edx, %eax, %eax ; X64-BMI1BMI2-NEXT: retq %val = load i32, i32* %w @@ -3103,15 +2976,13 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_c3_load_indexzext: ; X86-BMI1NOTBM: # %bb.0: +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl (%eax), %edx +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl (%edx), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movb $32, %cl -; X86-BMI1NOTBM-NEXT: subb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl %edx, %eax +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_c3_load_indexzext: @@ -3137,14 +3008,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr32_c3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl (%rdi), %edi +; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movb $32, %cl -; X64-BMI1NOTBM-NEXT: subb %dl, %cl -; X64-BMI1NOTBM-NEXT: movl $-1, %eax ; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %eax, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_c3_load_indexzext: @@ -3178,15 +3046,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_c4_commutative: ; X86-BMI1NOTBM: # %bb.0: +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl %edx, %eax +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_c4_commutative: @@ -3194,6 +3059,7 @@ ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1BMI2-NEXT: shrxl %ecx, {{[0-9]+}}(%esp), %ecx +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, %ecx, %eax ; X86-BMI1BMI2-NEXT: retl ; @@ -3213,17 +3079,14 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_c4_commutative: ; X64-BMI1BMI2: # %bb.0: ; X64-BMI1BMI2-NEXT: shrxl %esi, %edi, %eax +; X64-BMI1BMI2-NEXT: shll $0, %edx ; X64-BMI1BMI2-NEXT: bzhil %edx, %eax, %eax ; X64-BMI1BMI2-NEXT: retq %shifted = lshr i32 %val, %numskipbits @@ -3259,17 +3122,13 @@ ; X86-BMI1NOTBM: # %bb.0: ; X86-BMI1NOTBM-NEXT: pushl %esi ; X86-BMI1NOTBM-NEXT: subl $8, %esp -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %ecx ; X86-BMI1NOTBM-NEXT: shrl %cl, %edx -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: movl $-1, %esi -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: andl %edx, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, (%esp) +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %esi +; X86-BMI1NOTBM-NEXT: movl %ecx, (%esp) ; X86-BMI1NOTBM-NEXT: calll use32 ; X86-BMI1NOTBM-NEXT: movl %esi, %eax ; X86-BMI1NOTBM-NEXT: addl $8, %esp @@ -3283,6 +3142,7 @@ ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx ; X86-BMI1BMI2-NEXT: shrxl %ecx, {{[0-9]+}}(%esp), %edx +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, %edx, %esi ; X86-BMI1BMI2-NEXT: movl %ecx, (%esp) ; X86-BMI1BMI2-NEXT: calll use32 @@ -3313,12 +3173,8 @@ ; X64-BMI1NOTBM-NEXT: pushq %rbx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: movl $-1, %ebx -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %ebx -; X64-BMI1NOTBM-NEXT: andl %edi, %ebx +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %ebx ; X64-BMI1NOTBM-NEXT: movl %esi, %edi ; X64-BMI1NOTBM-NEXT: callq use32 ; X64-BMI1NOTBM-NEXT: movl %ebx, %eax @@ -3329,6 +3185,7 @@ ; X64-BMI1BMI2: # %bb.0: ; X64-BMI1BMI2-NEXT: pushq %rbx ; X64-BMI1BMI2-NEXT: shrxl %esi, %edi, %eax +; X64-BMI1BMI2-NEXT: shll $0, %edx ; X64-BMI1BMI2-NEXT: bzhil %edx, %eax, %ebx ; X64-BMI1BMI2-NEXT: movl %esi, %edi ; X64-BMI1BMI2-NEXT: callq use32 @@ -3462,12 +3319,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_c0: @@ -3596,13 +3449,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_c1_indexzext: ; X64-BMI1NOTBM: # %bb.0: +; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movb $64, %cl -; X64-BMI1NOTBM-NEXT: subb %dl, %cl -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_c1_indexzext: @@ -3740,15 +3591,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_c2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq (%rdi), %rdi +; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rax, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_c2_load: @@ -3882,14 +3729,12 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_c3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq (%rdi), %rdi +; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx +; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movb $64, %cl -; X64-BMI1NOTBM-NEXT: subb %dl, %cl -; X64-BMI1NOTBM-NEXT: movq $-1, %rax ; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rax, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_c3_load_indexzext: @@ -4026,12 +3871,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_c4_commutative: @@ -4214,12 +4055,8 @@ ; X64-BMI1NOTBM-NEXT: pushq %rbx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: movq $-1, %rbx -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rbx -; X64-BMI1NOTBM-NEXT: andq %rdi, %rbx +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rbx ; X64-BMI1NOTBM-NEXT: movq %rsi, %rdi ; X64-BMI1NOTBM-NEXT: callq use64 ; X64-BMI1NOTBM-NEXT: movq %rbx, %rax @@ -4263,14 +4100,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_d0: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_d0: @@ -4278,6 +4113,7 @@ ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1BMI2-NEXT: shrxl %ecx, {{[0-9]+}}(%esp), %ecx +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, %ecx, %eax ; X86-BMI1BMI2-NEXT: retl ; @@ -4297,17 +4133,14 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %edi -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_d0: ; X64-BMI1BMI2: # %bb.0: ; X64-BMI1BMI2-NEXT: shrxl %esi, %edi, %eax +; X64-BMI1BMI2-NEXT: shll $0, %edx ; X64-BMI1BMI2-NEXT: bzhil %edx, %eax, %eax ; X64-BMI1BMI2-NEXT: retq %shifted = lshr i32 %val, %numskipbits @@ -4331,13 +4164,12 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_d1_indexzext: ; X86-BMI1NOTBM: # %bb.0: +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: movb $32, %cl -; X86-BMI1NOTBM-NEXT: subb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_d1_indexzext: @@ -4363,11 +4195,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movb $32, %cl -; X64-BMI1NOTBM-NEXT: subb %dl, %cl -; X64-BMI1NOTBM-NEXT: shll %cl, %edi -; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_d1_indexzext: @@ -4400,15 +4229,13 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_d2_load: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl (%eax), %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl (%edx), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_d2_load: @@ -4417,6 +4244,7 @@ ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx ; X86-BMI1BMI2-NEXT: movb {{[0-9]+}}(%esp), %dl ; X86-BMI1BMI2-NEXT: shrxl %edx, (%ecx), %ecx +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, %ecx, %eax ; X86-BMI1BMI2-NEXT: retl ; @@ -4437,16 +4265,14 @@ ; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %eax, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_d2_load: ; X64-BMI1BMI2: # %bb.0: ; X64-BMI1BMI2-NEXT: shrxl %esi, (%rdi), %eax +; X64-BMI1BMI2-NEXT: shll $0, %edx ; X64-BMI1BMI2-NEXT: bzhil %edx, %eax, %eax ; X64-BMI1BMI2-NEXT: retq %val = load i32, i32* %w @@ -4472,14 +4298,13 @@ ; ; X86-BMI1NOTBM-LABEL: bextr32_d3_load_indexzext: ; X86-BMI1NOTBM: # %bb.0: +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl (%eax), %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: movb $32, %cl -; X86-BMI1NOTBM-NEXT: subb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl (%edx), %edx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bextr32_d3_load_indexzext: @@ -4507,10 +4332,8 @@ ; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: movb $32, %cl -; X64-BMI1NOTBM-NEXT: subb %dl, %cl -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %eax, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr32_d3_load_indexzext: @@ -4553,16 +4376,13 @@ ; X86-BMI1NOTBM: # %bb.0: ; X86-BMI1NOTBM-NEXT: pushl %esi ; X86-BMI1NOTBM-NEXT: subl $8, %esp -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %esi ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl %eax, %ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %esi -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %esi -; X86-BMI1NOTBM-NEXT: movl %eax, (%esp) +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %ecx +; X86-BMI1NOTBM-NEXT: shrl %cl, %edx +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, %edx, %esi +; X86-BMI1NOTBM-NEXT: movl %ecx, (%esp) ; X86-BMI1NOTBM-NEXT: calll use32 ; X86-BMI1NOTBM-NEXT: movl %esi, %eax ; X86-BMI1NOTBM-NEXT: addl $8, %esp @@ -4576,6 +4396,7 @@ ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx ; X86-BMI1BMI2-NEXT: shrxl %ecx, {{[0-9]+}}(%esp), %edx +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, %edx, %esi ; X86-BMI1BMI2-NEXT: movl %ecx, (%esp) ; X86-BMI1BMI2-NEXT: calll use32 @@ -4604,14 +4425,10 @@ ; X64-BMI1NOTBM-LABEL: bextr32_d5_skipextrauses: ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: pushq %rbx -; X64-BMI1NOTBM-NEXT: movl %edi, %ebx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %ebx -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %ebx -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %ebx +; X64-BMI1NOTBM-NEXT: shrl %cl, %edi +; X64-BMI1NOTBM-NEXT: shll $8, %edx +; X64-BMI1NOTBM-NEXT: bextrl %edx, %edi, %ebx ; X64-BMI1NOTBM-NEXT: movl %esi, %edi ; X64-BMI1NOTBM-NEXT: callq use32 ; X64-BMI1NOTBM-NEXT: movl %ebx, %eax @@ -4622,6 +4439,7 @@ ; X64-BMI1BMI2: # %bb.0: ; X64-BMI1BMI2-NEXT: pushq %rbx ; X64-BMI1BMI2-NEXT: shrxl %esi, %edi, %eax +; X64-BMI1BMI2-NEXT: shll $0, %edx ; X64-BMI1BMI2-NEXT: bzhil %edx, %eax, %ebx ; X64-BMI1BMI2-NEXT: movl %esi, %edi ; X64-BMI1BMI2-NEXT: callq use32 @@ -4792,12 +4610,8 @@ ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rdi -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_d0: @@ -4963,13 +4777,11 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_d1_indexzext: ; X64-BMI1NOTBM: # %bb.0: +; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movb $64, %cl -; X64-BMI1NOTBM-NEXT: subb %dl, %cl -; X64-BMI1NOTBM-NEXT: shlq %cl, %rdi -; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_d1_indexzext: @@ -5146,11 +4958,8 @@ ; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rax, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_d2_load: @@ -5320,13 +5129,12 @@ ; ; X64-BMI1NOTBM-LABEL: bextr64_d3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: +; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx ; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx ; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: movb $64, %cl -; X64-BMI1NOTBM-NEXT: subb %dl, %cl -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rax, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bextr64_d3_load_indexzext: @@ -5541,14 +5349,10 @@ ; X64-BMI1NOTBM-LABEL: bextr64_d5_skipextrauses: ; X64-BMI1NOTBM: # %bb.0: ; X64-BMI1NOTBM-NEXT: pushq %rbx -; X64-BMI1NOTBM-NEXT: movq %rdi, %rbx ; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rbx -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %edx, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rbx -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rbx +; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi +; X64-BMI1NOTBM-NEXT: shlq $8, %rdx +; X64-BMI1NOTBM-NEXT: bextrq %rdx, %rdi, %rbx ; X64-BMI1NOTBM-NEXT: movq %rsi, %rdi ; X64-BMI1NOTBM-NEXT: callq use64 ; X64-BMI1NOTBM-NEXT: movq %rbx, %rax Index: test/CodeGen/X86/extract-lowbits.ll =================================================================== --- test/CodeGen/X86/extract-lowbits.ll +++ test/CodeGen/X86/extract-lowbits.ll @@ -39,11 +39,9 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_a0: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_a0: @@ -63,11 +61,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_a0: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_a0: @@ -92,11 +87,9 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_a1_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_a1_indexzext: @@ -116,11 +109,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_a1_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_a1_indexzext: @@ -147,12 +137,10 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_a2_load: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl (%edx), %eax +; X86-BMI1NOTBM-NEXT: shll $8, %ecx +; X86-BMI1NOTBM-NEXT: bextrl %ecx, (%eax), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_a2_load: @@ -173,11 +161,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_a2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl (%rdi), %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, (%rdi), %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_a2_load: @@ -204,12 +189,10 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_a3_load_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl (%edx), %eax +; X86-BMI1NOTBM-NEXT: shll $8, %ecx +; X86-BMI1NOTBM-NEXT: bextrl %ecx, (%eax), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_a3_load_indexzext: @@ -230,11 +213,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_a3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl (%rdi), %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, (%rdi), %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_a3_load_indexzext: @@ -261,11 +241,9 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_a4_commutative: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $1, %eax -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: decl %eax -; X86-BMI1NOTBM-NEXT: andl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_a4_commutative: @@ -285,11 +263,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_a4_commutative: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: decl %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_a4_commutative: @@ -373,11 +348,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_a0: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_a0: @@ -459,11 +431,9 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_a1_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: # kill: def $esi killed $esi def $rsi +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_a1_indexzext: @@ -556,11 +526,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_a2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq (%rdi), %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, (%rdi), %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_a2_load: @@ -652,11 +619,9 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_a3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq (%rdi), %rax +; X64-BMI1NOTBM-NEXT: # kill: def $esi killed $esi def $rsi +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, (%rdi), %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_a3_load_indexzext: @@ -741,11 +706,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_a4_commutative: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: decq %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_a4_commutative: @@ -774,10 +736,9 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_b0: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: andnl {{[0-9]+}}(%esp), %eax, %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_b0: @@ -797,10 +758,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_b0: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl %edi, %eax, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_b0: @@ -825,10 +784,9 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_b1_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: andnl {{[0-9]+}}(%esp), %eax, %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_b1_indexzext: @@ -848,10 +806,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_b1_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl %edi, %eax, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_b1_indexzext: @@ -880,9 +836,8 @@ ; X86-BMI1NOTBM: # %bb.0: ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %edx -; X86-BMI1NOTBM-NEXT: shll %cl, %edx -; X86-BMI1NOTBM-NEXT: andnl (%eax), %edx, %eax +; X86-BMI1NOTBM-NEXT: shll $8, %ecx +; X86-BMI1NOTBM-NEXT: bextrl %ecx, (%eax), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_b2_load: @@ -903,10 +858,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_b2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl (%rdi), %eax, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, (%rdi), %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_b2_load: @@ -935,9 +888,8 @@ ; X86-BMI1NOTBM: # %bb.0: ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %edx -; X86-BMI1NOTBM-NEXT: shll %cl, %edx -; X86-BMI1NOTBM-NEXT: andnl (%eax), %edx, %eax +; X86-BMI1NOTBM-NEXT: shll $8, %ecx +; X86-BMI1NOTBM-NEXT: bextrl %ecx, (%eax), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_b3_load_indexzext: @@ -958,10 +910,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_b3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl (%rdi), %eax, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, (%rdi), %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_b3_load_indexzext: @@ -988,10 +938,9 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_b4_commutative: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: andnl {{[0-9]+}}(%esp), %eax, %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_b4_commutative: @@ -1011,10 +960,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_b4_commutative: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: andnl %edi, %eax, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_b4_commutative: @@ -1097,10 +1044,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_b0: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq %rdi, %rax, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_b0: @@ -1181,10 +1126,9 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_b1_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq %rdi, %rax, %rax +; X64-BMI1NOTBM-NEXT: # kill: def $esi killed $esi def $rsi +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_b1_indexzext: @@ -1272,10 +1216,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_b2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq (%rdi), %rax, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, (%rdi), %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_b2_load: @@ -1362,10 +1304,9 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_b3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq (%rdi), %rax, %rax +; X64-BMI1NOTBM-NEXT: # kill: def $esi killed $esi def $rsi +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, (%rdi), %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_b3_load_indexzext: @@ -1449,10 +1390,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_b4_commutative: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: movl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: andnq %rdi, %rax, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_b4_commutative: @@ -1482,17 +1421,15 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_c0: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_c0: ; X86-BMI1BMI2: # %bb.0: ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: retl ; @@ -1508,16 +1445,13 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_c0: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_c0: ; X64-BMI1BMI2: # %bb.0: +; X64-BMI1BMI2-NEXT: shll $0, %esi ; X64-BMI1BMI2-NEXT: bzhil %esi, %edi, %eax ; X64-BMI1BMI2-NEXT: retq %numhighbits = sub i32 32, %numlowbits @@ -1538,11 +1472,9 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_c1_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movb $32, %cl -; X86-BMI1NOTBM-NEXT: subb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_c1_indexzext: @@ -1562,11 +1494,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_c1_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movb $32, %cl -; X64-BMI1NOTBM-NEXT: subb %sil, %cl -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_c1_indexzext: @@ -1594,20 +1523,18 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_c2_load: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl (%edx), %eax +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %ecx +; X86-BMI1NOTBM-NEXT: shll $8, %ecx +; X86-BMI1NOTBM-NEXT: bextrl %ecx, (%eax), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_c2_load: ; X86-BMI1BMI2: # %bb.0: ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-BMI1BMI2-NEXT: bzhil %eax, (%ecx), %eax +; X86-BMI1BMI2-NEXT: shll $0, %ecx +; X86-BMI1BMI2-NEXT: bzhil %ecx, (%eax), %eax ; X86-BMI1BMI2-NEXT: retl ; ; X64-NOBMI-LABEL: bzhi32_c2_load: @@ -1622,16 +1549,13 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_c2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl (%rdi), %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, (%rdi), %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_c2_load: ; X64-BMI1BMI2: # %bb.0: +; X64-BMI1BMI2-NEXT: shll $0, %esi ; X64-BMI1BMI2-NEXT: bzhil %esi, (%rdi), %eax ; X64-BMI1BMI2-NEXT: retq %val = load i32, i32* %w @@ -1654,12 +1578,10 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_c3_load_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %edx -; X86-BMI1NOTBM-NEXT: movb $32, %cl -; X86-BMI1NOTBM-NEXT: subb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl (%edx), %eax +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl +; X86-BMI1NOTBM-NEXT: shll $8, %ecx +; X86-BMI1NOTBM-NEXT: bextrl %ecx, (%eax), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_c3_load_indexzext: @@ -1680,11 +1602,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_c3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movb $32, %cl -; X64-BMI1NOTBM-NEXT: subb %sil, %cl -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl (%rdi), %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, (%rdi), %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_c3_load_indexzext: @@ -1712,17 +1631,15 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_c4_commutative: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: movl $-1, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax -; X86-BMI1NOTBM-NEXT: andl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_c4_commutative: ; X86-BMI1BMI2: # %bb.0: ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: retl ; @@ -1738,16 +1655,13 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_c4_commutative: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: movl $-1, %eax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax -; X64-BMI1NOTBM-NEXT: andl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_c4_commutative: ; X64-BMI1BMI2: # %bb.0: +; X64-BMI1BMI2-NEXT: shll $0, %esi ; X64-BMI1BMI2-NEXT: bzhil %esi, %edi, %eax ; X64-BMI1BMI2-NEXT: retq %numhighbits = sub i32 32, %numlowbits @@ -1824,12 +1738,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_c0: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_c0: @@ -1907,11 +1817,9 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_c1_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movb $64, %cl -; X64-BMI1NOTBM-NEXT: subb %sil, %cl -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: # kill: def $esi killed $esi def $rsi +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_c1_indexzext: @@ -2001,12 +1909,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_c2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq (%rdi), %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, (%rdi), %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_c2_load: @@ -2094,11 +1998,9 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_c3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movb $64, %cl -; X64-BMI1NOTBM-NEXT: subb %sil, %cl -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq (%rdi), %rax +; X64-BMI1NOTBM-NEXT: # kill: def $esi killed $esi def $rsi +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, (%rdi), %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_c3_load_indexzext: @@ -2180,12 +2082,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_c4_commutative: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: movq $-1, %rax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax -; X64-BMI1NOTBM-NEXT: andq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_c4_commutative: @@ -2216,16 +2114,14 @@ ; X86-BMI1NOTBM-LABEL: bzhi32_d0: ; X86-BMI1NOTBM: # %bb.0: ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_d0: ; X86-BMI1BMI2: # %bb.0: ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-BMI1BMI2-NEXT: shll $0, %eax ; X86-BMI1BMI2-NEXT: bzhil %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: retl ; @@ -2241,16 +2137,13 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_d0: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %edi -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_d0: ; X64-BMI1BMI2: # %bb.0: +; X64-BMI1BMI2-NEXT: shll $0, %esi ; X64-BMI1BMI2-NEXT: bzhil %esi, %edi, %eax ; X64-BMI1BMI2-NEXT: retq %numhighbits = sub i32 32, %numlowbits @@ -2271,11 +2164,9 @@ ; ; X86-BMI1NOTBM-LABEL: bzhi32_d1_indexzext: ; X86-BMI1NOTBM: # %bb.0: -; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movb $32, %cl -; X86-BMI1NOTBM-NEXT: subb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %al +; X86-BMI1NOTBM-NEXT: shll $8, %eax +; X86-BMI1NOTBM-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_d1_indexzext: @@ -2295,11 +2186,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_d1_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movb $32, %cl -; X64-BMI1NOTBM-NEXT: subb %sil, %cl -; X64-BMI1NOTBM-NEXT: shll %cl, %edi -; X64-BMI1NOTBM-NEXT: shrl %cl, %edi -; X64-BMI1NOTBM-NEXT: movl %edi, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, %edi, %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_d1_indexzext: @@ -2328,19 +2216,17 @@ ; X86-BMI1NOTBM-LABEL: bzhi32_d2_load: ; X86-BMI1NOTBM: # %bb.0: ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl (%eax), %eax -; X86-BMI1NOTBM-NEXT: movl $32, %ecx -; X86-BMI1NOTBM-NEXT: subl {{[0-9]+}}(%esp), %ecx -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax +; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %ecx +; X86-BMI1NOTBM-NEXT: shll $8, %ecx +; X86-BMI1NOTBM-NEXT: bextrl %ecx, (%eax), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_d2_load: ; X86-BMI1BMI2: # %bb.0: ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-BMI1BMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-BMI1BMI2-NEXT: bzhil %eax, (%ecx), %eax +; X86-BMI1BMI2-NEXT: shll $0, %ecx +; X86-BMI1BMI2-NEXT: bzhil %ecx, (%eax), %eax ; X86-BMI1BMI2-NEXT: retl ; ; X64-NOBMI-LABEL: bzhi32_d2_load: @@ -2355,16 +2241,13 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_d2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax -; X64-BMI1NOTBM-NEXT: movl $32, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, (%rdi), %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_d2_load: ; X64-BMI1BMI2: # %bb.0: +; X64-BMI1BMI2-NEXT: shll $0, %esi ; X64-BMI1BMI2-NEXT: bzhil %esi, (%rdi), %eax ; X64-BMI1BMI2-NEXT: retq %val = load i32, i32* %w @@ -2388,11 +2271,9 @@ ; X86-BMI1NOTBM-LABEL: bzhi32_d3_load_indexzext: ; X86-BMI1NOTBM: # %bb.0: ; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-BMI1NOTBM-NEXT: movl (%eax), %eax -; X86-BMI1NOTBM-NEXT: movb $32, %cl -; X86-BMI1NOTBM-NEXT: subb {{[0-9]+}}(%esp), %cl -; X86-BMI1NOTBM-NEXT: shll %cl, %eax -; X86-BMI1NOTBM-NEXT: shrl %cl, %eax +; X86-BMI1NOTBM-NEXT: movb {{[0-9]+}}(%esp), %cl +; X86-BMI1NOTBM-NEXT: shll $8, %ecx +; X86-BMI1NOTBM-NEXT: bextrl %ecx, (%eax), %eax ; X86-BMI1NOTBM-NEXT: retl ; ; X86-BMI1BMI2-LABEL: bzhi32_d3_load_indexzext: @@ -2413,11 +2294,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi32_d3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax -; X64-BMI1NOTBM-NEXT: movb $32, %cl -; X64-BMI1NOTBM-NEXT: subb %sil, %cl -; X64-BMI1NOTBM-NEXT: shll %cl, %eax -; X64-BMI1NOTBM-NEXT: shrl %cl, %eax +; X64-BMI1NOTBM-NEXT: shll $8, %esi +; X64-BMI1NOTBM-NEXT: bextrl %esi, (%rdi), %eax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi32_d3_load_indexzext: @@ -2557,12 +2435,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_d0: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rdi -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movq %rdi, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_d0: @@ -2697,11 +2571,9 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_d1_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movb $64, %cl -; X64-BMI1NOTBM-NEXT: subb %sil, %cl -; X64-BMI1NOTBM-NEXT: shlq %cl, %rdi -; X64-BMI1NOTBM-NEXT: shrq %cl, %rdi -; X64-BMI1NOTBM-NEXT: movq %rdi, %rax +; X64-BMI1NOTBM-NEXT: # kill: def $esi killed $esi def $rsi +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, %rdi, %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_d1_indexzext: @@ -2842,12 +2714,8 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_d2_load: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax -; X64-BMI1NOTBM-NEXT: movl $64, %ecx -; X64-BMI1NOTBM-NEXT: subl %esi, %ecx -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, (%rdi), %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_d2_load: @@ -2986,11 +2854,9 @@ ; ; X64-BMI1NOTBM-LABEL: bzhi64_d3_load_indexzext: ; X64-BMI1NOTBM: # %bb.0: -; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax -; X64-BMI1NOTBM-NEXT: movb $64, %cl -; X64-BMI1NOTBM-NEXT: subb %sil, %cl -; X64-BMI1NOTBM-NEXT: shlq %cl, %rax -; X64-BMI1NOTBM-NEXT: shrq %cl, %rax +; X64-BMI1NOTBM-NEXT: # kill: def $esi killed $esi def $rsi +; X64-BMI1NOTBM-NEXT: shlq $8, %rsi +; X64-BMI1NOTBM-NEXT: bextrq %rsi, (%rdi), %rax ; X64-BMI1NOTBM-NEXT: retq ; ; X64-BMI1BMI2-LABEL: bzhi64_d3_load_indexzext: