[llvm-commits] [llvm] r166125 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/extract-concat.ll

Duncan Sands baldrick at free.fr
Thu Oct 18 00:26:38 PDT 2012


Hi Michael,

> Teach DAG combine to fold (extract_subvec (concat v1, ..) i) to v_i

> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Oct 17 15:48:33 2012
> @@ -8628,6 +8628,21 @@
>       }
>     }
>
> +  if (V->getOpcode() == ISD::CONCAT_VECTORS) {
> +    // Combine:
> +    //    (extract_subvec (concat V1, V2, ...), i)
> +    // Into:
> +    //    Vi if possible
> +    for (unsigned i = 0, e = V->getNumOperands(); i != e; ++i)
> +      if (V->getOperand(i).getValueType() != NVT)
> +        return SDValue();

since all operands are required to have the same type (see documentation in
ISDOpcodes.h) this loop is not needed.

Ciao, Duncan.

> +    unsigned Idx = dyn_cast<ConstantSDNode>(N->getOperand(1))->getZExtValue();
> +    unsigned NumElems = NVT.getVectorNumElements();
> +    assert((Idx % NumElems) == 0 &&
> +           "IDX in concat is not a multiple of the result vector length.");
> +    return V->getOperand(Idx / NumElems);
> +  }
> +
>     return SDValue();
>   }




More information about the llvm-commits mailing list