@@ -910,36 +910,32 @@ SDValue DAGTypeLegalizer::CreateStackStoreLoad(SDValue Op,
910910 return DAG.getLoad (DestVT, dl, Store, StackPtr, MachinePointerInfo (), Align);
911911}
912912
913- static SDValue MaybeBitcast (SelectionDAG &DAG, SDLoc DL, EVT VT,
914- SDValue Value) {
915- if (Value->getValueType (0 ) == VT)
916- return Value;
917- return DAG.getNode (ISD::BITCAST, DL, VT, Value);
918- }
919-
920913SDValue DAGTypeLegalizer::LowerBitcast (SDNode *Node) const {
921914 assert (Node->getOpcode () == ISD::BITCAST && " Unexpected opcode!" );
922915 // Handle bitcasting from v2i8 without hitting the default promotion
923916 // strategy which goes through stack memory.
924917 EVT FromVT = Node->getOperand (0 )->getValueType (0 );
925- if (FromVT != MVT::v2i8) {
918+ if (FromVT != MVT::v2i8)
926919 return SDValue ();
927- }
928920
929921 // Pack vector elements into i16 and bitcast to final type
930922 SDLoc DL (Node);
931923 SDValue Vec0 = DAG.getNode (ISD::EXTRACT_VECTOR_ELT, DL, MVT::i8 ,
932924 Node->getOperand (0 ), DAG.getIntPtrConstant (0 , DL));
933925 SDValue Vec1 = DAG.getNode (ISD::EXTRACT_VECTOR_ELT, DL, MVT::i8 ,
934926 Node->getOperand (0 ), DAG.getIntPtrConstant (1 , DL));
927+
935928 SDValue Extend0 = DAG.getNode (ISD::ZERO_EXTEND, DL, MVT::i16 , Vec0);
936929 SDValue Extend1 = DAG.getNode (ISD::ZERO_EXTEND, DL, MVT::i16 , Vec1);
937- SDValue Const8 = DAG.getConstant (8 , DL, MVT::i16 );
930+
931+ EVT ShiftAmtTy = TLI.getShiftAmountTy (Extend1.getValueType (), DAG.getDataLayout ());
932+ SDValue ShiftConst = DAG.getShiftAmountConstant (8 , ShiftAmtTy, DL);
938933 SDValue AsInt = DAG.getNode (
939- ISD::OR, DL, MVT::i16 ,
940- {Extend0, DAG.getNode (ISD::SHL, DL, MVT:: i16 , { Extend1, Const8})} );
934+ ISD::OR, DL, MVT::i16 , Extend0,
935+ DAG.getNode (ISD::SHL, DL, Extend1. getValueType (), Extend1, ShiftConst) );
941936 EVT ToVT = Node->getValueType (0 );
942- return MaybeBitcast (DAG, DL, ToVT, AsInt);
937+
938+ return DAG.getBitcast ( ToVT, AsInt);
943939}
944940
945941// / Replace the node's results with custom code provided by the target and
0 commit comments