diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-12-19 18:49:13 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-12-19 18:49:13 +0000 |
| commit | 84a00bd98a11011e8a0f2367c31988078b62e5ab (patch) | |
| tree | bb184b3c2e9dfe92d1e11cb991f8d53b0d008371 /llvm/test | |
| parent | 291470347a2e4d7b6aa0ecb854e61f074cc80590 (diff) | |
| download | bcm5719-llvm-84a00bd98a11011e8a0f2367c31988078b62e5ab.tar.gz bcm5719-llvm-84a00bd98a11011e8a0f2367c31988078b62e5ab.zip | |
[X86] Don't match TESTrr from (cmp (and X, Y), 0) during isel. Defer to post processing
The (cmp (and X, Y) 0) pattern is greedy and ends up forming a TESTrr and consuming the and when it might be better to use one of the BMI/TBM like BLSR or BLSI.
This patch moves removes the pattern from isel and adds a post processing check to combine TESTrr+ANDrr into just a TESTrr. With this patch we are able to select the BMI/TBM instructions, but we'll also emit a TESTrr when the result is compared to 0. In many cases the peephole pass will be able to use optimizeCompareInstr to remove the TEST, but its probably not perfect.
Differential Revision: https://reviews.llvm.org/D55870
llvm-svn: 349661
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/X86/bmi.ll | 24 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/tbm_patterns.ll | 27 |
2 files changed, 12 insertions, 39 deletions
diff --git a/llvm/test/CodeGen/X86/bmi.ll b/llvm/test/CodeGen/X86/bmi.ll index 5642f7c6e43..03d6df03c31 100644 --- a/llvm/test/CodeGen/X86/bmi.ll +++ b/llvm/test/CodeGen/X86/bmi.ll @@ -519,10 +519,7 @@ define i32 @blsi32_z(i32 %a, i32 %b) nounwind { define i32 @blsi32_z2(i32 %a, i32 %b, i32 %c) nounwind { ; X86-LABEL: blsi32_z2: ; X86: # %bb.0: -; X86-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-NEXT: movl %eax, %ecx -; X86-NEXT: negl %ecx -; X86-NEXT: testl %eax, %ecx +; X86-NEXT: blsil {{[0-9]+}}(%esp), %eax ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx ; X86-NEXT: cmovel %eax, %ecx @@ -532,9 +529,7 @@ define i32 @blsi32_z2(i32 %a, i32 %b, i32 %c) nounwind { ; X64-LABEL: blsi32_z2: ; X64: # %bb.0: ; X64-NEXT: movl %esi, %eax -; X64-NEXT: movl %edi, %ecx -; X64-NEXT: negl %ecx -; X64-NEXT: testl %edi, %ecx +; X64-NEXT: blsil %edi, %ecx ; X64-NEXT: cmovnel %edx, %eax ; X64-NEXT: retq %t0 = sub i32 0, %a @@ -629,9 +624,7 @@ define i64 @blsi64_z2(i64 %a, i64 %b, i64 %c) nounwind { ; X64-LABEL: blsi64_z2: ; X64: # %bb.0: ; X64-NEXT: movq %rsi, %rax -; X64-NEXT: movq %rdi, %rcx -; X64-NEXT: negq %rcx -; X64-NEXT: testq %rdi, %rcx +; X64-NEXT: blsiq %rdi, %rcx ; X64-NEXT: cmovneq %rdx, %rax ; X64-NEXT: retq %t0 = sub i64 0, %a @@ -875,9 +868,7 @@ define i32 @blsr32_z(i32 %a, i32 %b) nounwind { define i32 @blsr32_z2(i32 %a, i32 %b, i32 %c) nounwind { ; X86-LABEL: blsr32_z2: ; X86: # %bb.0: -; X86-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-NEXT: leal -1(%eax), %ecx -; X86-NEXT: testl %eax, %ecx +; X86-NEXT: blsrl {{[0-9]+}}(%esp), %eax ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx ; X86-NEXT: cmovel %eax, %ecx @@ -887,9 +878,7 @@ define i32 @blsr32_z2(i32 %a, i32 %b, i32 %c) nounwind { ; X64-LABEL: blsr32_z2: ; X64: # %bb.0: ; X64-NEXT: movl %esi, %eax -; X64-NEXT: # kill: def $edi killed $edi def $rdi -; X64-NEXT: leal -1(%rdi), %ecx -; X64-NEXT: testl %edi, %ecx +; X64-NEXT: blsrl %edi, %ecx ; X64-NEXT: cmovnel %edx, %eax ; X64-NEXT: retq %t0 = sub i32 %a, 1 @@ -984,8 +973,7 @@ define i64 @blsr64_z2(i64 %a, i64 %b, i64 %c) nounwind { ; X64-LABEL: blsr64_z2: ; X64: # %bb.0: ; X64-NEXT: movq %rsi, %rax -; X64-NEXT: leaq -1(%rdi), %rcx -; X64-NEXT: testq %rdi, %rcx +; X64-NEXT: blsrq %rdi, %rcx ; X64-NEXT: cmovneq %rdx, %rax ; X64-NEXT: retq %t0 = sub i64 %a, 1 diff --git a/llvm/test/CodeGen/X86/tbm_patterns.ll b/llvm/test/CodeGen/X86/tbm_patterns.ll index 7ebc5dd0d12..65cc92ca853 100644 --- a/llvm/test/CodeGen/X86/tbm_patterns.ll +++ b/llvm/test/CodeGen/X86/tbm_patterns.ll @@ -150,9 +150,7 @@ define i32 @test_x86_tbm_blcfill_u32_z2(i32 %a, i32 %b, i32 %c) nounwind { ; CHECK-LABEL: test_x86_tbm_blcfill_u32_z2: ; CHECK: # %bb.0: ; CHECK-NEXT: movl %esi, %eax -; CHECK-NEXT: # kill: def $edi killed $edi def $rdi -; CHECK-NEXT: leal 1(%rdi), %ecx -; CHECK-NEXT: testl %edi, %ecx +; CHECK-NEXT: blcfilll %edi, %ecx ; CHECK-NEXT: cmovnel %edx, %eax ; CHECK-NEXT: retq %t0 = add i32 %a, 1 @@ -189,8 +187,7 @@ define i64 @test_x86_tbm_blcfill_u64_z2(i64 %a, i64 %b, i64 %c) nounwind { ; CHECK-LABEL: test_x86_tbm_blcfill_u64_z2: ; CHECK: # %bb.0: ; CHECK-NEXT: movq %rsi, %rax -; CHECK-NEXT: leaq 1(%rdi), %rcx -; CHECK-NEXT: testq %rdi, %rcx +; CHECK-NEXT: blcfillq %rdi, %rcx ; CHECK-NEXT: cmovneq %rdx, %rax ; CHECK-NEXT: retq %t0 = add i64 %a, 1 @@ -334,10 +331,7 @@ define i32 @test_x86_tbm_blcic_u32_z2(i32 %a, i32 %b, i32 %c) nounwind { ; CHECK-LABEL: test_x86_tbm_blcic_u32_z2: ; CHECK: # %bb.0: ; CHECK-NEXT: movl %esi, %eax -; CHECK-NEXT: movl %edi, %ecx -; CHECK-NEXT: notl %ecx -; CHECK-NEXT: incl %edi -; CHECK-NEXT: testl %ecx, %edi +; CHECK-NEXT: blcicl %edi, %ecx ; CHECK-NEXT: cmovnel %edx, %eax ; CHECK-NEXT: retq %t0 = xor i32 %a, -1 @@ -377,10 +371,7 @@ define i64 @test_x86_tbm_blcic_u64_z2(i64 %a, i64 %b, i64 %c) nounwind { ; CHECK-LABEL: test_x86_tbm_blcic_u64_z2: ; CHECK: # %bb.0: ; CHECK-NEXT: movq %rsi, %rax -; CHECK-NEXT: movq %rdi, %rcx -; CHECK-NEXT: notq %rcx -; CHECK-NEXT: incq %rdi -; CHECK-NEXT: testq %rcx, %rdi +; CHECK-NEXT: blcicq %rdi, %rcx ; CHECK-NEXT: cmovneq %rdx, %rax ; CHECK-NEXT: retq %t0 = xor i64 %a, -1 @@ -823,10 +814,7 @@ define i32 @test_x86_tbm_tzmsk_u32_z2(i32 %a, i32 %b, i32 %c) nounwind { ; CHECK-LABEL: test_x86_tbm_tzmsk_u32_z2: ; CHECK: # %bb.0: ; CHECK-NEXT: movl %esi, %eax -; CHECK-NEXT: movl %edi, %ecx -; CHECK-NEXT: notl %ecx -; CHECK-NEXT: decl %edi -; CHECK-NEXT: testl %edi, %ecx +; CHECK-NEXT: tzmskl %edi, %ecx ; CHECK-NEXT: cmovnel %edx, %eax ; CHECK-NEXT: retq %t0 = xor i32 %a, -1 @@ -866,10 +854,7 @@ define i64 @test_x86_tbm_tzmsk_u64_z2(i64 %a, i64 %b, i64 %c) nounwind { ; CHECK-LABEL: test_x86_tbm_tzmsk_u64_z2: ; CHECK: # %bb.0: ; CHECK-NEXT: movq %rsi, %rax -; CHECK-NEXT: movq %rdi, %rcx -; CHECK-NEXT: notq %rcx -; CHECK-NEXT: decq %rdi -; CHECK-NEXT: testq %rdi, %rcx +; CHECK-NEXT: tzmskq %rdi, %rcx ; CHECK-NEXT: cmovneq %rdx, %rax ; CHECK-NEXT: retq %t0 = xor i64 %a, -1 |

