[LLVMbugs] [Bug 21223] New: Assertion in X86 backend - vector extract/shuffle

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 9 05:41:19 PDT 2014


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

            Bug ID: 21223
           Summary: Assertion in X86 backend - vector extract/shuffle
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: fraser at codeplay.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I'm trying to compile some OpenCL code:

  void kernel foo_kernel(__global float3 * in, __global float2 * out) {
      const int idx = get_global_id(0);
      float2 tmp = in[idx].hi;
      out[idx] = tmp;
  }

I get the following assertion coming from the X86 backend:

  ../external/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1467:
llvm::SDValue llvm::SelectionDAG::getVectorShuffle(llvm::EVT, llvm::SDLoc,
llvm::SDValue, llvm::SDValue, const int*): Assertion `VT == N1.getValueType()
&& VT == N2.getValueType() && "Invalid VECTOR_SHUFFLE"' failed.

The offending IR snippet is here:
  %7 = load <3 x float> addrspace(1)* %arrayidx, align 16
  %8 = shufflevector <3 x float> %7, <3 x float> undef, <2 x i32> <i32 0, i32
1>

I've done a bit of digging...

It's coming from the XFormVExtractWithShuffleIntoLoad() in X86ISelLowering.cpp.
It calls DAG.getVectorShuffle() near the end of the function.

'InVec' has value type MVT::v2f64. 'Shuffle' has value type MVT::v2i64. This
difference is what causes the assert.

'Shuffle' is created one line before, with SDValue Shuffle = (UnaryShuffle) ?
DAG.getUNDEF(VT) : InVec.getOperand(1);

Since 'UnaryShuffle' is true, Shuffle has type corresponding to 'VT' which is
MVT::v2i64.

VT was created near the beginning of the function from 'InVec.getValueType()'.

  EVT VT = InVec.getValueType();

  if (InVec.getOpcode() == ISD::BITCAST) {
    // Don't duplicate a load with other uses.
    if (!InVec.hasOneUse())
      return SDValue();
    EVT BCVT = InVec.getOperand(0).getValueType();
    if (BCVT.getVectorNumElements() != VT.getVectorNumElements())
      return SDValue();
    InVec = InVec.getOperand(0);
  }


What I've noticed is that InVec is changed in that if block, but VT isn't
updated. Indeed, if I re-assign VT inside that if block, then I no longer get
the assertion. I'm new to the X86 backend, though, so I don't know if doing
that is valid in the grander scheme of things.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141009/becc88bb/attachment.html>


More information about the llvm-bugs mailing list