From cd95e03cf0617718b31d653813a7a655f5cfad63 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Wed, 12 Sep 2018 20:58:48 +0000 Subject: [PATCH] [Hexagon] Use legalized type for extracted elements in scalarizeShuffle Scalarization of a shuffle will break up the source vectors into individual elements, and use them to assemble the resulting vector. An element type of a legal vector type may not necessarily be a legal scalar type, so make sure that the extracted values are extended to a legal scalar type. llvm-svn: 342079 --- llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp index 988ed92..0b4bd23 100644 --- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp @@ -1338,9 +1338,11 @@ bool HvxSelector::scalarizeShuffle(ArrayRef Mask, const SDLoc &dl, MVT SingleTy = getSingleVT(MVT::i8); SmallVector Ops; + LLVMContext &Ctx = *DAG.getContext(); + MVT LegalTy = Lower.getTypeToTransformTo(Ctx, ElemTy).getSimpleVT(); for (int I : Mask) { if (I < 0) { - Ops.push_back(ISel.selectUndef(dl, ElemTy)); + Ops.push_back(ISel.selectUndef(dl, LegalTy)); continue; } SDValue Vec; @@ -1360,7 +1362,7 @@ bool HvxSelector::scalarizeShuffle(ArrayRef Mask, const SDLoc &dl, } } SDValue Idx = DAG.getConstant(M, dl, MVT::i32); - SDValue Ex = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, ElemTy, {Vec, Idx}); + SDValue Ex = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, LegalTy, {Vec, Idx}); SDValue L = Lower.LowerOperation(Ex, DAG); assert(L.getNode()); Ops.push_back(L); -- 2.7.4