Skip to content

Commit fb92f86

Browse files
committed
[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.
1 parent 992698c commit fb92f86

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ define i64 @pdep64_load(i64 %x, i64* %y) {
4141
ret i64 %tmp
4242
}
4343

44+
define i64 @pdep64_anyext(i32 %x) {
45+
; CHECK-LABEL: pdep64_anyext:
46+
; CHECK: # %bb.0:
47+
; CHECK-NEXT: movslq %edi, %rax
48+
; CHECK-NEXT: movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555
49+
; CHECK-NEXT: pdepq %rcx, %rax, %rax
50+
; CHECK-NEXT: retq
51+
%x1 = sext i32 %x to i64
52+
%tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x1, i64 6148914691236517205)
53+
ret i64 %tmp
54+
}
55+
4456
declare i64 @llvm.x86.bmi.pdep.64(i64, i64)
4557

4658
define i64 @pext64(i64 %x, i64 %y) {

llvm/test/CodeGen/X86/bmi2.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ define i32 @pdep32_load(i32 %x, i32* %y) {
7676
ret i32 %tmp
7777
}
7878

79+
define i32 @pdep32_anyext(i16 %x) {
80+
; X86-LABEL: pdep32_anyext:
81+
; X86: # %bb.0:
82+
; X86-NEXT: movswl {{[0-9]+}}(%esp), %eax
83+
; X86-NEXT: movl $-1431655766, %ecx # imm = 0xAAAAAAAA
84+
; X86-NEXT: pdepl %ecx, %eax, %eax
85+
; X86-NEXT: retl
86+
;
87+
; X64-LABEL: pdep32_anyext:
88+
; X64: # %bb.0:
89+
; X64-NEXT: movswl %di, %eax
90+
; X64-NEXT: movl $-1431655766, %ecx # imm = 0xAAAAAAAA
91+
; X64-NEXT: pdepl %ecx, %eax, %eax
92+
; X64-NEXT: retq
93+
%x1 = sext i16 %x to i32
94+
%tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x1, i32 -1431655766)
95+
ret i32 %tmp
96+
}
97+
7998
declare i32 @llvm.x86.bmi.pdep.32(i32, i32)
8099

81100
define i32 @pext32(i32 %x, i32 %y) {

0 commit comments

Comments
 (0)