[llvm] fb92f86 - [X86] Add some demanded bits test cases for PDEP with constant mask

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 22:57:34 PDT 2020


Author: Craig Topper
Date: 2020-09-17T22:48:19-07:00
New Revision: fb92f863f6849c7fa01f5487bd09544ee0856c59

URL: https://github.com/llvm/llvm-project/commit/fb92f863f6849c7fa01f5487bd09544ee0856c59
DIFF: https://github.com/llvm/llvm-project/commit/fb92f863f6849c7fa01f5487bd09544ee0856c59.diff

LOG: [X86] Add some demanded bits test cases for PDEP with constant mask

The number of ones in the mask for the PDEP determines how many
bits of the other operand are used. If the mask is constant we
can use this to build a mask for SimplifyDemandedBits. This can
be used to replace the extends in the test with anyextend.

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/bmi2-x86_64.ll
    llvm/test/CodeGen/X86/bmi2.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/bmi2-x86_64.ll b/llvm/test/CodeGen/X86/bmi2-x86_64.ll
index bb03138ccf76..9f8214d5b3b5 100644
--- a/llvm/test/CodeGen/X86/bmi2-x86_64.ll
+++ b/llvm/test/CodeGen/X86/bmi2-x86_64.ll
@@ -41,6 +41,18 @@ define i64 @pdep64_load(i64 %x, i64* %y)   {
   ret i64 %tmp
 }
 
+define i64 @pdep64_anyext(i32 %x)   {
+; CHECK-LABEL: pdep64_anyext:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movslq %edi, %rax
+; CHECK-NEXT:    movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555
+; CHECK-NEXT:    pdepq %rcx, %rax, %rax
+; CHECK-NEXT:    retq
+  %x1 = sext i32 %x to i64
+  %tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x1, i64 6148914691236517205)
+  ret i64 %tmp
+}
+
 declare i64 @llvm.x86.bmi.pdep.64(i64, i64)
 
 define i64 @pext64(i64 %x, i64 %y)   {

diff  --git a/llvm/test/CodeGen/X86/bmi2.ll b/llvm/test/CodeGen/X86/bmi2.ll
index bf78cb4f72ef..94bddf4cd603 100644
--- a/llvm/test/CodeGen/X86/bmi2.ll
+++ b/llvm/test/CodeGen/X86/bmi2.ll
@@ -76,6 +76,25 @@ define i32 @pdep32_load(i32 %x, i32* %y)   {
   ret i32 %tmp
 }
 
+define i32 @pdep32_anyext(i16 %x)   {
+; X86-LABEL: pdep32_anyext:
+; X86:       # %bb.0:
+; X86-NEXT:    movswl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    movl $-1431655766, %ecx # imm = 0xAAAAAAAA
+; X86-NEXT:    pdepl %ecx, %eax, %eax
+; X86-NEXT:    retl
+;
+; X64-LABEL: pdep32_anyext:
+; X64:       # %bb.0:
+; X64-NEXT:    movswl %di, %eax
+; X64-NEXT:    movl $-1431655766, %ecx # imm = 0xAAAAAAAA
+; X64-NEXT:    pdepl %ecx, %eax, %eax
+; X64-NEXT:    retq
+  %x1 = sext i16 %x to i32
+  %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x1, i32 -1431655766)
+  ret i32 %tmp
+}
+
 declare i32 @llvm.x86.bmi.pdep.32(i32, i32)
 
 define i32 @pext32(i32 %x, i32 %y)   {


        


More information about the llvm-commits mailing list