diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-10-11 07:51:13 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-10-11 07:51:13 +0000 |
commit | 4225f4adfff842284e22d9e61e66a9eccd1ea426 (patch) | |
tree | 88ad978f5b19d7fd9bd1693c179153c51e5f2d5d /llvm/test/CodeGen/X86/extract-bits.ll | |
parent | b2e51090a427be5a804af53ac3615672ae356074 (diff) | |
download | bcm5719-llvm-4225f4adfff842284e22d9e61e66a9eccd1ea426.tar.gz bcm5719-llvm-4225f4adfff842284e22d9e61e66a9eccd1ea426.zip |
[X86][BMI1]: X86DAGToDAGISel: select BEXTR from x & ~(-1 << nbits) pattern
Summary:
As discussed in D48491, we can't really do this in the TableGen,
since we need to produce *two* instructions. This only implements
one single pattern. The other 3 patterns will be in follow-ups.
I'm not sure yet if we want to also fuse shift into here
(i.e `(x >> start) & ...`)
Reviewers: RKSimon, craig.topper, spatel
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D52304
llvm-svn: 344224
Diffstat (limited to 'llvm/test/CodeGen/X86/extract-bits.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/extract-bits.ll | 139 |
1 files changed, 46 insertions, 93 deletions
diff --git a/llvm/test/CodeGen/X86/extract-bits.ll b/llvm/test/CodeGen/X86/extract-bits.ll index 98c9ab271cb..b16aeb3d350 100644 --- a/llvm/test/CodeGen/X86/extract-bits.ll +++ b/llvm/test/CodeGen/X86/extract-bits.ll @@ -1507,16 +1507,12 @@ define i32 @bextr32_b0(i32 %val, i32 %numskipbits, i32 %numlowbits) nounwind { ; ; 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: @@ -1544,10 +1540,8 @@ define i32 @bextr32_b0(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: 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: @@ -1580,16 +1574,12 @@ define i32 @bextr32_b1_indexzext(i32 %val, i8 zeroext %numskipbits, i8 zeroext % ; ; 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: @@ -1617,10 +1607,8 @@ define i32 @bextr32_b1_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: 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: @@ -1656,17 +1644,13 @@ define i32 @bextr32_b2_load(i32* %w, i32 %numskipbits, i32 %numlowbits) nounwind ; ; 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: @@ -1697,10 +1681,8 @@ define i32 @bextr32_b2_load(i32* %w, i32 %numskipbits, i32 %numlowbits) nounwind ; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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: @@ -1735,17 +1717,13 @@ define i32 @bextr32_b3_load_indexzext(i32* %w, i8 zeroext %numskipbits, i8 zeroe ; ; 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: @@ -1776,10 +1754,8 @@ define i32 @bextr32_b3_load_indexzext(i32* %w, i8 zeroext %numskipbits, i8 zeroe ; X64-BMI1NOTBM-NEXT: movl (%rdi), %eax ; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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: @@ -1815,16 +1791,12 @@ define i32 @bextr32_b4_commutative(i32 %val, i32 %numskipbits, i32 %numlowbits) ; ; 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: @@ -1852,10 +1824,8 @@ define i32 @bextr32_b4_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: 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: @@ -1896,24 +1866,19 @@ define i32 @bextr32_b5_skipextrauses(i32 %val, i32 %numskipbits, i32 %numlowbits ; ; 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: @@ -1952,10 +1917,8 @@ define i32 @bextr32_b5_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, %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 @@ -2106,10 +2069,8 @@ define i64 @bextr64_b0(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: 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: @@ -2245,13 +2206,12 @@ define i64 @bextr64_b1_indexzext(i64 %val, i8 zeroext %numskipbits, i8 zeroext % ; ; 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: # kill: def $cl killed $cl killed $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: @@ -2399,10 +2359,8 @@ define i64 @bextr64_b2_load(i64* %w, i64 %numskipbits, i64 %numlowbits) nounwind ; X64-BMI1NOTBM-NEXT: movq (%rdi), %rax ; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $rcx ; 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: @@ -2543,14 +2501,13 @@ define i64 @bextr64_b3_load_indexzext(i64* %w, i8 zeroext %numskipbits, i8 zeroe ; ; X64-BMI1NOTBM-LABEL: bextr64_b3_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), %rax ; X64-BMI1NOTBM-NEXT: # kill: def $cl killed $cl killed $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: @@ -2694,10 +2651,8 @@ define i64 @bextr64_b4_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: 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: @@ -2876,12 +2831,10 @@ define i64 @bextr64_b5_skipextrauses(i64 %val, i64 %numskipbits, i64 %numlowbits ; X64-BMI1NOTBM-LABEL: bextr64_b5_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: 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 |