[LLVMbugs] [Bug 13310] New: [AVX2, perf] could extract vector scales of 2/4/8 from gathers

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 9 12:51:25 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13310

             Bug #: 13310
           Summary: [AVX2,perf] could extract vector scales of 2/4/8 from
                    gathers
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: matt at pharr.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This code scales a vector of indices by 4 before doing a gather (this will
happen frequently):

declare <8 x float> @llvm.x86.avx2.gather.d.ps.256(<8 x float>, i8*, <8 x i32>,
<8 x float>, i8) nounwind readonly

define <8 x float> @foo(float* noalias %a, <8 x i32> %index, <8 x i32> %__mask)
nounwind {
allocas:
  %a_ptr = bitcast float* %a to i8*
  %scaled_varying.i = mul <8 x i32> %index, <i32 4, i32 4, i32 4, i32 4, i32 4,
i32 4, i32 4, i32 4>
  %mask.i = bitcast <8 x i32> %__mask to <8 x float>
  %v.i = call <8 x float> @llvm.x86.avx2.gather.d.ps.256(<8 x float> undef, i8*
%a_ptr,
                  <8 x i32> %scaled_varying.i, <8 x float> %mask.i, i8 1)
nounwind
  ret <8 x float> %v.i
}

It generates this asm, doing a vector multiply:

    vpbroadcastd    LCPI0_0(%rip), %ymm2   # LCPI_0_0 -> 4
    vpmulld    %ymm2, %ymm0, %ymm0
    vgatherdps    %ymm0, (%rdi,%ymm0), %ymm1

It would be nice if the x86 code generator detected this case and instead
generated:

    vgatherdps    %ymm0, (%rdi,%ymm0,4), %ymm1

(I realize that front-ends could do this as well, by eliminating the vector
multiply and passing "4" as the last argument of the gather intrinsic. 
However, the equivalent pattern is detected for scalar memory ops already, and
it'd be nice to do this for all users in the code generator...)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list