[X86][BMI1]: X86DAGToDAGISel: select BEXTR from x & ((1 << nbits) + (-1)) pattern

Summary:
Trivial continuation of D52304.
While this pattern is not canonical, we do select it in the BZHI case,
so this should not be any different.

Reviewers: RKSimon, craig.topper, spatel

Reviewed By: RKSimon

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D52348

llvm-svn: 344902
This commit is contained in:
Roman Lebedev 2018-10-22 13:54:17 +00:00
parent 7eae99999d
commit 13c5ab2e27
3 changed files with 130 additions and 224 deletions

View File

@ -2700,6 +2700,24 @@ bool X86DAGToDAGISel::matchBEXTR(SDNode *Node) {
SDValue NBits;
// a) x & ((1 << nbits) + (-1))
auto matchPatternA = [&NBits](SDValue Mask) -> bool {
// Match `add`. Must only have one use!
if (Mask->getOpcode() != ISD::ADD || !Mask->hasOneUse())
return false;
// We should be adding all-ones constant (i.e. subtracting one.)
if (!isAllOnesConstant(Mask->getOperand(1)))
return false;
// Match `1 << nbits`. Must only have one use!
SDValue M0 = Mask->getOperand(0);
if (M0->getOpcode() != ISD::SHL || !M0->hasOneUse())
return false;
if (!isOneConstant(M0->getOperand(0)))
return false;
NBits = M0->getOperand(1);
return true;
};
// b) x & ~(-1 << nbits)
auto matchPatternB = [&NBits](SDValue Mask) -> bool {
// Match `~()`. Must only have one use!
@ -2715,9 +2733,10 @@ bool X86DAGToDAGISel::matchBEXTR(SDNode *Node) {
return true;
};
auto matchLowBitMask = [&matchPatternB](SDValue Mask) -> bool {
// FIXME: patterns a, c, d.
return matchPatternB(Mask);
auto matchLowBitMask = [&matchPatternA,
&matchPatternB](SDValue Mask) -> bool {
// FIXME: patterns c, d.
return matchPatternA(Mask) || matchPatternB(Mask);
};
SDValue X = Node->getOperand(0);

View File

@ -48,17 +48,12 @@ define i32 @bextr32_a0(i32 %val, i32 %numskipbits, i32 %numlowbits) nounwind {
;
; 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:
@ -86,11 +81,8 @@ define i32 @bextr32_a0(i32 %val, i32 %numskipbits, i32 %numlowbits) nounwind {
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -123,17 +115,12 @@ define i32 @bextr32_a1_indexzext(i32 %val, i8 zeroext %numskipbits, i8 zeroext %
;
; 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:
@ -161,11 +148,8 @@ define i32 @bextr32_a1_indexzext(i32 %val, i8 zeroext %numskipbits, i8 zeroext %
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -201,18 +185,13 @@ define i32 @bextr32_a2_load(i32* %w, i32 %numskipbits, i32 %numlowbits) nounwind
;
; 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:
@ -240,14 +219,11 @@ define i32 @bextr32_a2_load(i32* %w, i32 %numskipbits, i32 %numlowbits) nounwind
; X64-BMI1NOTBM-LABEL: bextr32_a2_load:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl (%rdi), %esi
; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx
; X64-BMI1NOTBM-NEXT: shrl %cl, %esi
; 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 %esi, %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:
@ -282,18 +258,13 @@ define i32 @bextr32_a3_load_indexzext(i32* %w, i8 zeroext %numskipbits, i8 zeroe
;
; 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:
@ -321,14 +292,11 @@ define i32 @bextr32_a3_load_indexzext(i32* %w, i8 zeroext %numskipbits, i8 zeroe
; X64-BMI1NOTBM-LABEL: bextr32_a3_load_indexzext:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl (%rdi), %esi
; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx
; X64-BMI1NOTBM-NEXT: shrl %cl, %esi
; 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 %esi, %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:
@ -364,17 +332,12 @@ define i32 @bextr32_a4_commutative(i32 %val, i32 %numskipbits, i32 %numlowbits)
;
; 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:
@ -402,11 +365,8 @@ define i32 @bextr32_a4_commutative(i32 %val, i32 %numskipbits, i32 %numlowbits)
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -447,25 +407,19 @@ define i32 @bextr32_a5_skipextrauses(i32 %val, i32 %numskipbits, i32 %numlowbits
;
; 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:
@ -504,11 +458,8 @@ define i32 @bextr32_a5_skipextrauses(i32 %val, i32 %numskipbits, i32 %numlowbits
; 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
@ -662,11 +613,8 @@ define i64 @bextr64_a0(i64 %val, i64 %numskipbits, i64 %numlowbits) nounwind {
; X64-BMI1NOTBM-NEXT: movq %rsi, %rcx
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $rcx
; 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:
@ -805,14 +753,12 @@ define i64 @bextr64_a1_indexzext(i64 %val, i8 zeroext %numskipbits, i8 zeroext %
;
; 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: # kill: def $cl killed $cl killed $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:
@ -960,14 +906,11 @@ define i64 @bextr64_a2_load(i64* %w, i64 %numskipbits, i64 %numlowbits) nounwind
; X64-BMI1NOTBM-LABEL: bextr64_a2_load:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movq %rsi, %rcx
; X64-BMI1NOTBM-NEXT: movq (%rdi), %rsi
; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $rcx
; X64-BMI1NOTBM-NEXT: shrq %cl, %rsi
; 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 %rsi, %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:
@ -1111,15 +1054,13 @@ define i64 @bextr64_a3_load_indexzext(i64* %w, i8 zeroext %numskipbits, i8 zeroe
;
; X64-BMI1NOTBM-LABEL: bextr64_a3_load_indexzext:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: # kill: def $edx killed $edx def $rdx
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movq (%rdi), %rsi
; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $ecx
; X64-BMI1NOTBM-NEXT: shrq %cl, %rsi
; 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 %rsi, %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:
@ -1266,11 +1207,8 @@ define i64 @bextr64_a4_commutative(i64 %val, i64 %numskipbits, i64 %numlowbits)
; X64-BMI1NOTBM-NEXT: movq %rsi, %rcx
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $rcx
; 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:
@ -1454,13 +1392,10 @@ define i64 @bextr64_a5_skipextrauses(i64 %val, i64 %numskipbits, i64 %numlowbits
; X64-BMI1NOTBM-LABEL: bextr64_a5_skipextrauses:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: pushq %rbx
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movq %rsi, %rcx
; 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

View File

@ -39,11 +39,9 @@ define i32 @bzhi32_a0(i32 %val, i32 %numlowbits) nounwind {
;
; 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:
@ -64,12 +62,8 @@ define i32 @bzhi32_a0(i32 %val, i32 %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi32_a0:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -94,11 +88,9 @@ define i32 @bzhi32_a1_indexzext(i32 %val, i8 zeroext %numlowbits) nounwind {
;
; 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:
@ -119,12 +111,8 @@ define i32 @bzhi32_a1_indexzext(i32 %val, i8 zeroext %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi32_a1_indexzext:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -151,12 +139,10 @@ define i32 @bzhi32_a2_load(i32* %w, i32 %numlowbits) nounwind {
;
; 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:
@ -178,12 +164,8 @@ define i32 @bzhi32_a2_load(i32* %w, i32 %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi32_a2_load:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -210,12 +192,10 @@ define i32 @bzhi32_a3_load_indexzext(i32* %w, i8 zeroext %numlowbits) nounwind {
;
; 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:
@ -237,12 +217,8 @@ define i32 @bzhi32_a3_load_indexzext(i32* %w, i8 zeroext %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi32_a3_load_indexzext:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -269,11 +245,9 @@ define i32 @bzhi32_a4_commutative(i32 %val, i32 %numlowbits) nounwind {
;
; 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:
@ -294,12 +268,8 @@ define i32 @bzhi32_a4_commutative(i32 %val, i32 %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi32_a4_commutative:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -384,12 +354,8 @@ define i64 @bzhi64_a0(i64 %val, i64 %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi64_a0:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movq %rsi, %rcx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $rcx
; 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:
@ -472,12 +438,9 @@ define i64 @bzhi64_a1_indexzext(i64 %val, i8 zeroext %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi64_a1_indexzext:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -571,12 +534,8 @@ define i64 @bzhi64_a2_load(i64* %w, i64 %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi64_a2_load:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movq %rsi, %rcx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $rcx
; 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:
@ -669,12 +628,9 @@ define i64 @bzhi64_a3_load_indexzext(i64* %w, i8 zeroext %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi64_a3_load_indexzext:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movl %esi, %ecx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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:
@ -760,12 +716,8 @@ define i64 @bzhi64_a4_commutative(i64 %val, i64 %numlowbits) nounwind {
;
; X64-BMI1NOTBM-LABEL: bzhi64_a4_commutative:
; X64-BMI1NOTBM: # %bb.0:
; X64-BMI1NOTBM-NEXT: movq %rsi, %rcx
; X64-BMI1NOTBM-NEXT: movl $1, %eax
; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $rcx
; 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: