[LLVMbugs] [Bug 12465] New: __builtin_shufflevector produces incorrect IR when mask argument is a vector

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 5 09:18:20 PDT 2012


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

             Bug #: 12465
           Summary: __builtin_shufflevector produces incorrect IR when
                    mask argument is a vector
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dneto.llvm at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8330
  --> http://llvm.org/bugs/attachment.cgi?id=8330
Fix and test for __builtin_shufflevector code gen when mask is a vector

Found in top-of-tree at r154095.

ScalarExprEmitter::VisitShuffleVectorExpr produces incorrect IR when the mask
argument is a vector.

The *comment* is correct:

    // newv = undef
    // mask = mask & maskbits
    // for each elt
    //   n = extract mask i
    //   x = extract val n
    //   newv = insert newv, x, i

But the code it generates is more like this:

    // newv = undef
    // mask = mask & maskbits
    // for each elt
    //   n = extract mask i
    //   x = extract val n
    //   newv = insert newv, x, n    (The "n" here is wrong.)

I could not find detailed enough lit-based tests to cover this case, but there
were none.

I'm attaching a fix and test.   The test has a comment showing exactly where
things go wrong.  Please consider for submission after editing.

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