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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to