[LLVMbugs] [Bug 13850] New: opportunity for small improvement to zero-initialization codegen [AVX]

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Sep 14 13:45:17 PDT 2012


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

             Bug #: 13850
           Summary: opportunity for small improvement to
                    zero-initialization codegen [AVX]
           Product: new-bugs
           Version: trunk
          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


Created attachment 9218
  --> http://llvm.org/bugs/attachment.cgi?id=9218
llvm bitcode

The attached test case initializes the given <8 x float> pointer to zero via a
call to llvm.memset.  With AVX, if the pointer is declared to have 16 byte
alignment, then the following code is generated:

% llc -mattr=+avx x.ll -o -
[...]
_orthoBasis1:                           ## @orthoBasis1
## BB#0:                                ## %allocas
    vxorps    %xmm0, %xmm0, %xmm0
    vmovaps    %xmm0, 80(%rdi)
    vmovaps    %xmm0, 64(%rdi)
    vmovaps    %xmm0, 48(%rdi)
    vmovaps    %xmm0, 32(%rdi)
    vmovaps    %xmm0, 16(%rdi)
    vmovaps    %xmm0, (%rdi)
    ret

It seems like this could be done with half as many vmovaps calls if a ymm
register was used instead?

If the pointer is declared as having 4 byte alignment, then a sequence of movqs
is generated:

_orthoBasis:                            ## @orthoBasis
## BB#0:                                ## %allocas
    movq    $0, 88(%rdi)
    movq    $0, 80(%rdi)
    movq    $0, 72(%rdi)
    movq    $0, 64(%rdi)
    movq    $0, 56(%rdi)
    movq    $0, 48(%rdi)
    movq    $0, 40(%rdi)
    movq    $0, 32(%rdi)
    movq    $0, 24(%rdi)
    movq    $0, 16(%rdi)
    movq    $0, 8(%rdi)
    movq    $0, (%rdi)
    ret

Doing these with a vmovups of a zeroed-out ymm register also seems like it'd be
an improvement.

-- 
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