@@ -1656,6 +1656,11 @@ SDValue SelectionDAG::getConstant(const ConstantInt &Val, const SDLoc &DL,
16561656 EVT EltVT = VT.getScalarType ();
16571657 const ConstantInt *Elt = &Val;
16581658
1659+ // Vector splats are explicit within the DAG, with ConstantSDNode holding the
1660+ // to-be-splatted scalar ConstantInt.
1661+ if (isa<VectorType>(Elt->getType ()))
1662+ Elt = ConstantInt::get (*getContext (), Elt->getValue ());
1663+
16591664 // In some cases the vector type is legal but the element type is illegal and
16601665 // needs to be promoted, for example v8i8 on ARM. In this case, promote the
16611666 // inserted value (the type does not need to match the vector element type).
@@ -1809,6 +1814,12 @@ SDValue SelectionDAG::getConstantFP(const ConstantFP &V, const SDLoc &DL,
18091814 assert (VT.isFloatingPoint () && " Cannot create integer FP constant!" );
18101815
18111816 EVT EltVT = VT.getScalarType ();
1817+ const ConstantFP *Elt = &V;
1818+
1819+ // Vector splats are explicit within the DAG, with ConstantFPSDNode holding
1820+ // the to-be-splatted scalar ConstantFP.
1821+ if (isa<VectorType>(Elt->getType ()))
1822+ Elt = ConstantFP::get (*getContext (), Elt->getValue ());
18121823
18131824 // Do the map lookup using the actual bit pattern for the floating point
18141825 // value, so that we don't have problems with 0.0 comparing equal to -0.0, and
@@ -1817,15 +1828,15 @@ SDValue SelectionDAG::getConstantFP(const ConstantFP &V, const SDLoc &DL,
18171828 SDVTList VTs = getVTList (EltVT);
18181829 FoldingSetNodeID ID;
18191830 AddNodeIDNode (ID, Opc, VTs, {});
1820- ID.AddPointer (&V );
1831+ ID.AddPointer (Elt );
18211832 void *IP = nullptr ;
18221833 SDNode *N = nullptr ;
18231834 if ((N = FindNodeOrInsertPos (ID, DL, IP)))
18241835 if (!VT.isVector ())
18251836 return SDValue (N, 0 );
18261837
18271838 if (!N) {
1828- N = newSDNode<ConstantFPSDNode>(isTarget, &V , VTs);
1839+ N = newSDNode<ConstantFPSDNode>(isTarget, Elt , VTs);
18291840 CSEMap.InsertNode (N, IP);
18301841 InsertNode (N);
18311842 }
0 commit comments