summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-10-11 18:06:07 +0000
committerCraig Topper <craig.topper@intel.com>2018-10-11 18:06:07 +0000
commitfb2ac8969e4bf1fb545f27128faa1ad852e18760 (patch)
tree3bf2231c2b6465db8d772f2087c26d298add0532 /llvm/test
parente502f8b3158e7534f5c78a12d3ded3f15ebec216 (diff)
downloadbcm5719-llvm-fb2ac8969e4bf1fb545f27128faa1ad852e18760.tar.gz
bcm5719-llvm-fb2ac8969e4bf1fb545f27128faa1ad852e18760.zip
[X86] Restore X86ISelDAGToDAG::matchBEXTRFromAnd. Teach address matching to create a BEXTR pattern from a (shl (and X, mask >> C1) if C1 can be folded into addressing mode.
This is an alternative to D53080 since I think using a BEXTR for a shifted mask is definitely an improvement when the shl can be absorbed into addressing mode. The other cases I'm less sure about. We already have several tricks for handling an and of a shift in address matching. This adds a new case for BEXTR. I've moved the BEXTR matching code back to X86ISelDAGToDAG to allow it to match. I suppose alternatively we could directly emit a X86ISD::BEXTR node that isel could pattern match. But I'm trying to view BEXTR matching as an isel concern so DAG combine can see 'and' and 'shift' operations that are well understood. We did lose a couple cases from tbm_patterns.ll, but I think there are ways to recover that. I've also put back the manual load folding code in matchBEXTRFromAnd that I removed a few months ago in r324939. This gives us some more freedom to make decisions based on the ability to fold a load. I haven't done anything with that yet. Differential Revision: https://reviews.llvm.org/D53126 llvm-svn: 344270
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/extract-bits.ll78
-rw-r--r--llvm/test/CodeGen/X86/tbm_patterns.ll6
2 files changed, 66 insertions, 18 deletions
diff --git a/llvm/test/CodeGen/X86/extract-bits.ll b/llvm/test/CodeGen/X86/extract-bits.ll
index b16aeb3d350..06f316b14d0 100644
--- a/llvm/test/CodeGen/X86/extract-bits.ll
+++ b/llvm/test/CodeGen/X86/extract-bits.ll
@@ -5568,23 +5568,69 @@ define i64 @bextr64_d5_skipextrauses(i64 %val, i64 %numskipbits, i64 %numlowbits
; https://bugs.llvm.org/show_bug.cgi?id=38938
define void @pr38938(i32* %a0, i64* %a1) {
-; X86-LABEL: pr38938:
-; X86: # %bb.0:
-; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
-; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
-; X86-NEXT: movl (%ecx), %ecx
-; X86-NEXT: shrl $19, %ecx
-; X86-NEXT: andl $4092, %ecx # imm = 0xFFC
-; X86-NEXT: incl (%eax,%ecx)
-; X86-NEXT: retl
+; X86-NOBMI-LABEL: pr38938:
+; X86-NOBMI: # %bb.0:
+; X86-NOBMI-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NOBMI-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NOBMI-NEXT: movl (%ecx), %ecx
+; X86-NOBMI-NEXT: shrl $19, %ecx
+; X86-NOBMI-NEXT: andl $4092, %ecx # imm = 0xFFC
+; X86-NOBMI-NEXT: incl (%eax,%ecx)
+; X86-NOBMI-NEXT: retl
;
-; X64-LABEL: pr38938:
-; X64: # %bb.0:
-; X64-NEXT: movq (%rsi), %rax
-; X64-NEXT: shrq $19, %rax
-; X64-NEXT: andl $4092, %eax # imm = 0xFFC
-; X64-NEXT: incl (%rdi,%rax)
-; X64-NEXT: retq
+; X86-BMI1NOTBM-LABEL: pr38938:
+; X86-BMI1NOTBM: # %bb.0:
+; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-BMI1NOTBM-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-BMI1NOTBM-NEXT: movl $2581, %edx # imm = 0xA15
+; X86-BMI1NOTBM-NEXT: bextrl %edx, (%ecx), %ecx
+; X86-BMI1NOTBM-NEXT: incl (%eax,%ecx,4)
+; X86-BMI1NOTBM-NEXT: retl
+;
+; X86-BMI1TBM-LABEL: pr38938:
+; X86-BMI1TBM: # %bb.0:
+; X86-BMI1TBM-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-BMI1TBM-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-BMI1TBM-NEXT: bextrl $2581, (%ecx), %ecx # imm = 0xA15
+; X86-BMI1TBM-NEXT: incl (%eax,%ecx,4)
+; X86-BMI1TBM-NEXT: retl
+;
+; X86-BMI1NOTBMBMI2-LABEL: pr38938:
+; X86-BMI1NOTBMBMI2: # %bb.0:
+; X86-BMI1NOTBMBMI2-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-BMI1NOTBMBMI2-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-BMI1NOTBMBMI2-NEXT: movl $2581, %edx # imm = 0xA15
+; X86-BMI1NOTBMBMI2-NEXT: bextrl %edx, (%ecx), %ecx
+; X86-BMI1NOTBMBMI2-NEXT: incl (%eax,%ecx,4)
+; X86-BMI1NOTBMBMI2-NEXT: retl
+;
+; X64-NOBMI-LABEL: pr38938:
+; X64-NOBMI: # %bb.0:
+; X64-NOBMI-NEXT: movq (%rsi), %rax
+; X64-NOBMI-NEXT: shrq $19, %rax
+; X64-NOBMI-NEXT: andl $4092, %eax # imm = 0xFFC
+; X64-NOBMI-NEXT: incl (%rdi,%rax)
+; X64-NOBMI-NEXT: retq
+;
+; X64-BMI1NOTBM-LABEL: pr38938:
+; X64-BMI1NOTBM: # %bb.0:
+; X64-BMI1NOTBM-NEXT: movl $2581, %eax # imm = 0xA15
+; X64-BMI1NOTBM-NEXT: bextrq %rax, (%rsi), %rax
+; X64-BMI1NOTBM-NEXT: incl (%rdi,%rax,4)
+; X64-BMI1NOTBM-NEXT: retq
+;
+; X64-BMI1TBM-LABEL: pr38938:
+; X64-BMI1TBM: # %bb.0:
+; X64-BMI1TBM-NEXT: bextrq $2581, (%rsi), %rax # imm = 0xA15
+; X64-BMI1TBM-NEXT: incl (%rdi,%rax,4)
+; X64-BMI1TBM-NEXT: retq
+;
+; X64-BMI1NOTBMBMI2-LABEL: pr38938:
+; X64-BMI1NOTBMBMI2: # %bb.0:
+; X64-BMI1NOTBMBMI2-NEXT: movl $2581, %eax # imm = 0xA15
+; X64-BMI1NOTBMBMI2-NEXT: bextrq %rax, (%rsi), %rax
+; X64-BMI1NOTBMBMI2-NEXT: incl (%rdi,%rax,4)
+; X64-BMI1NOTBMBMI2-NEXT: retq
%tmp = load i64, i64* %a1, align 8
%tmp1 = lshr i64 %tmp, 21
%tmp2 = and i64 %tmp1, 1023
diff --git a/llvm/test/CodeGen/X86/tbm_patterns.ll b/llvm/test/CodeGen/X86/tbm_patterns.ll
index 2b335ea4268..6865cc5a0ef 100644
--- a/llvm/test/CodeGen/X86/tbm_patterns.ll
+++ b/llvm/test/CodeGen/X86/tbm_patterns.ll
@@ -53,7 +53,8 @@ define i32 @test_x86_tbm_bextri_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
; CHECK-LABEL: test_x86_tbm_bextri_u32_z2:
; CHECK: # %bb.0:
; CHECK-NEXT: movl %esi, %eax
-; CHECK-NEXT: bextrl $3076, %edi, %ecx # imm = 0xC04
+; CHECK-NEXT: shrl $4, %edi
+; CHECK-NEXT: testl $4095, %edi # imm = 0xFFF
; CHECK-NEXT: cmovnel %edx, %eax
; CHECK-NEXT: retq
%t0 = lshr i32 %a, 4
@@ -113,7 +114,8 @@ define i64 @test_x86_tbm_bextri_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
; CHECK-LABEL: test_x86_tbm_bextri_u64_z2:
; CHECK: # %bb.0:
; CHECK-NEXT: movq %rsi, %rax
-; CHECK-NEXT: bextrl $3076, %edi, %ecx # imm = 0xC04
+; CHECK-NEXT: shrl $4, %edi
+; CHECK-NEXT: testl $4095, %edi # imm = 0xFFF
; CHECK-NEXT: cmovneq %rdx, %rax
; CHECK-NEXT: retq
%t0 = lshr i64 %a, 4
OpenPOWER on IntegriCloud