[llvm] [X86][SelectionDAG] Fix the Gather's base and index by modifying the Scale value (PR #134979)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 16 10:01:27 PDT 2025


================
@@ -5094,11 +5047,13 @@ define {<16 x float>, <16 x float>} @test_gather_16f32_mask_index_pair(ptr %x, p
 ; X86-SKX-NEXT:    vpmovd2m %zmm0, %k1
 ; X86-SKX-NEXT:    movl {{[0-9]+}}(%esp), %eax
 ; X86-SKX-NEXT:    movl {{[0-9]+}}(%esp), %ecx
-; X86-SKX-NEXT:    vpslld $4, (%ecx), %zmm2
+; X86-SKX-NEXT:    vmovdqu64 (%ecx), %zmm0
+; X86-SKX-NEXT:    vpandd {{\.?LCPI[0-9]+_[0-9]+}}{1to16}, %zmm0, %zmm0
+; X86-SKX-NEXT:    vpaddd %zmm0, %zmm0, %zmm2
----------------
RKSimon wrote:

I think we can handle this by adding an additional SimplifyDemandedBits call to combineGatherScatter - for cases where PtrVT == IndexSVT, then we can use the Scale value (assuming its Pow2 which it should be) to demand just the lower bits of the Index param - which should remove the VPANDD.

https://github.com/llvm/llvm-project/pull/134979


More information about the llvm-commits mailing list