[LLVMbugs] [Bug 10986] New: [AVX] incorrect code generated (related to shuffles?)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 22 07:59:32 PDT 2011


           Summary: [AVX] incorrect code generated (related to shuffles?)
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: matt at pharr.org
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=7324)
 --> (http://llvm.org/bugs/attachment.cgi?id=7324)

The attached test case has code that a 'max' reduction over a vector--given the
vector [0 2 0 4 0 6 0 8], it is supposed to return the scalar value '8'.  It
returns the correct answer with SSE:

% llc -o bug.o -filetype=obj bug.ll && gcc bug.c bug.o && ./a.out

But not with AVX:

% llc -mattr=+avx -o bug.o -filetype=obj bug.ll && gcc bug.c bug.o && ./a.out

I've tried to simplify the bitcode a bit, and have annotated each line with the
expected value of each assignment, just to make it easier to follow.  The basic
strategy is that it takes the 8xi32 vector, shuffles it into 2 4xi32 vectors [0
2 0 4] and [0 6 0 8], does a SSE4 pmaxsd (getting [0 6 0 8], with the data
given in this case), then it shuffles that into [0 6 xx xx] [0 8 xx xx], does a
pmaxsd on that to get [0 8 xx xx], and finally shuffles that one more time to
get [0 xx xx xx] and [8 xx xx xx], does a final pmaxsd to get [8 xx xx xx],
from which it extracts the first element and returns it.

Some archeology in the changelists tells me that this checkin broke this code
(it had worked previously):

commit e97190fdf875843e8161a942f2046fd3ef81330f
Author: Bruno Cardoso Lopes <bruno.cardoso at gmail.com>
Date:   Tue Sep 20 23:19:33 2011 +0000

    Add a DAGCombine for subvector extracts to remove useless chains of
    subvector inserts and extracts. Initial patch by Rackover, Zvi with
    some tweak done by me.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140204

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