Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,29 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BITCAST(SDNode *N) {
}
}

// TODO: Handle big endian
if (!NOutVT.isVector() && InOp.getValueType().isVector() &&
DAG.getDataLayout().isLittleEndian()) {
// Pad the vector operand with undef and cast to a wider integer.
EVT EltVT = InOp.getValueType().getVectorElementType();
TypeSize EltSize = EltVT.getSizeInBits();
TypeSize OutSize = NOutVT.getSizeInBits();

if (OutSize.hasKnownScalarFactor(EltSize)) {
unsigned NumEltsWithPadding = OutSize.getKnownScalarFactor(EltSize);
EVT WideVecVT =
EVT::getVectorVT(*DAG.getContext(), EltVT, NumEltsWithPadding);

if (isTypeLegal(WideVecVT)) {
SDValue Inserted = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, WideVecVT,
DAG.getUNDEF(WideVecVT), InOp,
DAG.getVectorIdxConstant(0, dl));

return DAG.getNode(ISD::BITCAST, dl, NOutVT, Inserted);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a shift after this for Big Endian like the TypeWidenVector case on line 540?

}
}
}

return DAG.getNode(ISD::ANY_EXTEND, dl, NOutVT,
CreateStackStoreLoad(InOp, OutVT));
}
Expand Down
Loading
Loading