@@ -3191,20 +3191,25 @@ SDValue NVPTXTargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
31913191
31923192SDValue
31933193NVPTXTargetLowering::LowerSTOREVector (SDValue Op, SelectionDAG &DAG) const {
3194- SDNode *N = Op.getNode ();
3194+ MemSDNode *N = cast<MemSDNode>( Op.getNode () );
31953195 SDValue Val = N->getOperand (1 );
31963196 SDLoc DL (N);
3197- EVT ValVT = Val.getValueType ();
3197+ const EVT ValVT = Val.getValueType ();
3198+ const EVT MemVT = N->getMemoryVT ();
3199+
3200+ // If we're truncating as part of the store, avoid lowering to a StoreV node.
3201+ // TODO: consider relaxing this restriction.
3202+ if (ValVT != MemVT)
3203+ return SDValue ();
31983204
31993205 const auto NumEltsAndEltVT = getVectorLoweringShape (ValVT);
32003206 if (!NumEltsAndEltVT)
32013207 return SDValue ();
32023208 const auto [NumElts, EltVT] = NumEltsAndEltVT.value ();
32033209
3204- MemSDNode *MemSD = cast<MemSDNode>(N);
32053210 const DataLayout &TD = DAG.getDataLayout ();
32063211
3207- Align Alignment = MemSD ->getAlign ();
3212+ Align Alignment = N ->getAlign ();
32083213 Align PrefAlign = TD.getPrefTypeAlign (ValVT.getTypeForEVT (*DAG.getContext ()));
32093214 if (Alignment < PrefAlign) {
32103215 // This store is not sufficiently aligned, so bail out and let this vector
@@ -3267,7 +3272,7 @@ NVPTXTargetLowering::LowerSTOREVector(SDValue Op, SelectionDAG &DAG) const {
32673272
32683273 SDValue NewSt =
32693274 DAG.getMemIntrinsicNode (Opcode, DL, DAG.getVTList (MVT::Other), Ops,
3270- MemSD ->getMemoryVT (), MemSD ->getMemOperand ());
3275+ N ->getMemoryVT (), N ->getMemOperand ());
32713276
32723277 // return DCI.CombineTo(N, NewSt, true);
32733278 return NewSt;
@@ -5762,20 +5767,23 @@ static void ReplaceBITCAST(SDNode *Node, SelectionDAG &DAG,
57625767// / ReplaceVectorLoad - Convert vector loads into multi-output scalar loads.
57635768static void ReplaceLoadVector (SDNode *N, SelectionDAG &DAG,
57645769 SmallVectorImpl<SDValue> &Results) {
5765- const EVT ResVT = N->getValueType (0 );
5766- SDLoc DL (N);
5770+ LoadSDNode *LD = cast<LoadSDNode>(N);
5771+ const EVT ResVT = LD->getValueType (0 );
5772+ const EVT MemVT = LD->getMemoryVT ();
5773+
5774+ // If we're doing sign/zero extension as part of the load, avoid lowering to
5775+ // a LoadV node. TODO: consider relaxing this restriction.
5776+ if (ResVT != MemVT)
5777+ return ;
57675778
57685779 const auto NumEltsAndEltVT = getVectorLoweringShape (ResVT);
57695780 if (!NumEltsAndEltVT)
57705781 return ;
57715782 const auto [NumElts, EltVT] = NumEltsAndEltVT.value ();
57725783
5773- LoadSDNode *LD = cast<LoadSDNode>(N);
5774-
57755784 Align Alignment = LD->getAlign ();
57765785 const auto &TD = DAG.getDataLayout ();
5777- Align PrefAlign =
5778- TD.getPrefTypeAlign (LD->getMemoryVT ().getTypeForEVT (*DAG.getContext ()));
5786+ Align PrefAlign = TD.getPrefTypeAlign (MemVT.getTypeForEVT (*DAG.getContext ()));
57795787 if (Alignment < PrefAlign) {
57805788 // This load is not sufficiently aligned, so bail out and let this vector
57815789 // load be scalarized. Note that we may still be able to emit smaller
@@ -5806,9 +5814,10 @@ static void ReplaceLoadVector(SDNode *N, SelectionDAG &DAG,
58065814 break ;
58075815 }
58085816 }
5817+ SDLoc DL (LD);
58095818
58105819 // Copy regular operands
5811- SmallVector<SDValue, 8 > OtherOps (N ->ops ());
5820+ SmallVector<SDValue, 8 > OtherOps (LD ->ops ());
58125821
58135822 // The select routine does not have access to the LoadSDNode instance, so
58145823 // pass along the extension information
0 commit comments