[llvm] 326a615 - [X86] replace-load-and-with-bzhi.ll - add commuted test cases to show failure to fold

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 6 09:30:06 PDT 2024


Author: Simon Pilgrim
Date: 2024-10-06T17:29:33+01:00
New Revision: 326a61506ab08337a6b34283d3bbb316018edf42

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

LOG: [X86] replace-load-and-with-bzhi.ll - add commuted test cases to show failure to fold

Tests showing combineAndLoadToBZHI commutation folding is currently broken

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/replace-load-and-with-bzhi.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/replace-load-and-with-bzhi.ll b/llvm/test/CodeGen/X86/replace-load-and-with-bzhi.ll
index e2a33731512928..46fe1b95afaad4 100644
--- a/llvm/test/CodeGen/X86/replace-load-and-with-bzhi.ll
+++ b/llvm/test/CodeGen/X86/replace-load-and-with-bzhi.ll
@@ -26,6 +26,28 @@ entry:
   ret i32 %and
 }
 
+define i32 @f32_bzhi_commute(i32 %x, i32 %y) local_unnamed_addr {
+; X64-LABEL: f32_bzhi_commute:
+; X64:       # %bb.0: # %entry
+; X64-NEXT:    movl %edi, %eax
+; X64-NEXT:    movslq %esi, %rcx
+; X64-NEXT:    andl fill_table32(,%rcx,4), %eax
+; X64-NEXT:    retq
+;
+; X86-LABEL: f32_bzhi_commute:
+; X86:       # %bb.0: # %entry
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    andl fill_table32(,%ecx,4), %eax
+; X86-NEXT:    retl
+entry:
+  %idxprom = sext i32 %y to i64
+  %arrayidx = getelementptr inbounds [32 x i32], ptr @fill_table32, i64 0, i64 %idxprom
+  %0 = load i32, ptr %arrayidx, align 4
+  %and = and i32 %x, %0
+  ret i32 %and
+}
+
 define i32 @f32_bzhi_partial(i32 %x, i32 %y) local_unnamed_addr {
 ; X64-LABEL: f32_bzhi_partial:
 ; X64:       # %bb.0: # %entry
@@ -45,6 +67,28 @@ entry:
   ret i32 %and
 }
 
+define i32 @f32_bzhi_partial_commute(i32 %x, i32 %y) local_unnamed_addr {
+; X64-LABEL: f32_bzhi_partial_commute:
+; X64:       # %bb.0: # %entry
+; X64-NEXT:    movl %edi, %eax
+; X64-NEXT:    movslq %esi, %rcx
+; X64-NEXT:    andl fill_table32_partial(,%rcx,4), %eax
+; X64-NEXT:    retq
+;
+; X86-LABEL: f32_bzhi_partial_commute:
+; X86:       # %bb.0: # %entry
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    andl fill_table32_partial(,%ecx,4), %eax
+; X86-NEXT:    retl
+entry:
+  %idxprom = sext i32 %y to i64
+  %arrayidx = getelementptr inbounds [17 x i32], ptr @fill_table32_partial, i64 0, i64 %idxprom
+  %0 = load i32, ptr %arrayidx, align 4
+  %and = and i32 %x, %0
+  ret i32 %and
+}
+
 define i64 @f64_bzhi(i64 %x, i64 %y) local_unnamed_addr {
 ; X64-LABEL: f64_bzhi:
 ; X64:       # %bb.0: # %entry
@@ -66,6 +110,28 @@ entry:
   ret i64 %and
 }
 
+define i64 @f64_bzhi_commute(i64 %x, i64 %y) local_unnamed_addr {
+; X64-LABEL: f64_bzhi_commute:
+; X64:       # %bb.0: # %entry
+; X64-NEXT:    movq %rdi, %rax
+; X64-NEXT:    andq fill_table64(,%rsi,8), %rax
+; X64-NEXT:    retq
+;
+; X86-LABEL: f64_bzhi_commute:
+; X86:       # %bb.0: # %entry
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT:    andl fill_table64(,%ecx,8), %eax
+; X86-NEXT:    andl fill_table64+4(,%ecx,8), %edx
+; X86-NEXT:    retl
+entry:
+  %arrayidx = getelementptr inbounds [64 x i64], ptr @fill_table64, i64 0, i64 %y
+  %0 = load i64, ptr %arrayidx, align 8
+  %and = and i64 %x, %0
+  ret i64 %and
+}
+
 define i64 @f64_bzhi_partial(i64 %x, i64 %y) local_unnamed_addr {
 ; X64-LABEL: f64_bzhi_partial:
 ; X64:       # %bb.0: # %entry
@@ -87,3 +153,24 @@ entry:
   ret i64 %and
 }
 
+define i64 @f64_bzhi_partial_commute(i64 %x, i64 %y) local_unnamed_addr {
+; X64-LABEL: f64_bzhi_partial_commute:
+; X64:       # %bb.0: # %entry
+; X64-NEXT:    movq %rdi, %rax
+; X64-NEXT:    andq fill_table64_partial(,%rsi,8), %rax
+; X64-NEXT:    retq
+;
+; X86-LABEL: f64_bzhi_partial_commute:
+; X86:       # %bb.0: # %entry
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT:    andl fill_table64_partial(,%ecx,8), %eax
+; X86-NEXT:    andl fill_table64_partial+4(,%ecx,8), %edx
+; X86-NEXT:    retl
+entry:
+  %arrayidx = getelementptr inbounds [51 x i64], ptr @fill_table64_partial, i64 0, i64 %y
+  %0 = load i64, ptr %arrayidx, align 8
+  %and = and i64 %x, %0
+  ret i64 %and
+}


        


More information about the llvm-commits mailing list