<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Assertion in X86 backend - vector extract/shuffle"
   href="http://llvm.org/bugs/show_bug.cgi?id=21223">21223</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion in X86 backend - vector extract/shuffle
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>fraser@codeplay.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>