@@ -566,6 +566,29 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BITCAST(SDNode *N) {
566566 }
567567 }
568568
569+ // TODO: Handle big endian
570+ if (!NOutVT.isVector () && InOp.getValueType ().isVector () &&
571+ DAG.getDataLayout ().isLittleEndian ()) {
572+ // Pad the vector operand with undef and cast to a wider integer.
573+ EVT EltVT = InOp.getValueType ().getVectorElementType ();
574+ TypeSize EltSize = EltVT.getSizeInBits ();
575+ TypeSize OutSize = NOutVT.getSizeInBits ();
576+
577+ if (OutSize.hasKnownScalarFactor (EltSize)) {
578+ unsigned NumEltsWithPadding = OutSize.getKnownScalarFactor (EltSize);
579+ EVT WideVecVT =
580+ EVT::getVectorVT (*DAG.getContext (), EltVT, NumEltsWithPadding);
581+
582+ if (isTypeLegal (WideVecVT)) {
583+ SDValue Inserted = DAG.getNode (ISD::INSERT_SUBVECTOR, dl, WideVecVT,
584+ DAG.getUNDEF (WideVecVT), InOp,
585+ DAG.getVectorIdxConstant (0 , dl));
586+
587+ return DAG.getNode (ISD::BITCAST, dl, NOutVT, Inserted);
588+ }
589+ }
590+ }
591+
569592 return DAG.getNode (ISD::ANY_EXTEND, dl, NOutVT,
570593 CreateStackStoreLoad (InOp, OutVT));
571594}
0 commit comments