@@ -3191,20 +3191,25 @@ SDValue NVPTXTargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
3191
3191
3192
3192
SDValue
3193
3193
NVPTXTargetLowering::LowerSTOREVector (SDValue Op, SelectionDAG &DAG) const {
3194
- SDNode *N = Op.getNode ();
3194
+ MemSDNode *N = cast<MemSDNode>( Op.getNode () );
3195
3195
SDValue Val = N->getOperand (1 );
3196
3196
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 ();
3198
3204
3199
3205
const auto NumEltsAndEltVT = getVectorLoweringShape (ValVT);
3200
3206
if (!NumEltsAndEltVT)
3201
3207
return SDValue ();
3202
3208
const auto [NumElts, EltVT] = NumEltsAndEltVT.value ();
3203
3209
3204
- MemSDNode *MemSD = cast<MemSDNode>(N);
3205
3210
const DataLayout &TD = DAG.getDataLayout ();
3206
3211
3207
- Align Alignment = MemSD ->getAlign ();
3212
+ Align Alignment = N ->getAlign ();
3208
3213
Align PrefAlign = TD.getPrefTypeAlign (ValVT.getTypeForEVT (*DAG.getContext ()));
3209
3214
if (Alignment < PrefAlign) {
3210
3215
// This store is not sufficiently aligned, so bail out and let this vector
@@ -3267,7 +3272,7 @@ NVPTXTargetLowering::LowerSTOREVector(SDValue Op, SelectionDAG &DAG) const {
3267
3272
3268
3273
SDValue NewSt =
3269
3274
DAG.getMemIntrinsicNode (Opcode, DL, DAG.getVTList (MVT::Other), Ops,
3270
- MemSD ->getMemoryVT (), MemSD ->getMemOperand ());
3275
+ N ->getMemoryVT (), N ->getMemOperand ());
3271
3276
3272
3277
// return DCI.CombineTo(N, NewSt, true);
3273
3278
return NewSt;
@@ -5762,20 +5767,23 @@ static void ReplaceBITCAST(SDNode *Node, SelectionDAG &DAG,
5762
5767
// / ReplaceVectorLoad - Convert vector loads into multi-output scalar loads.
5763
5768
static void ReplaceLoadVector (SDNode *N, SelectionDAG &DAG,
5764
5769
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 ;
5767
5778
5768
5779
const auto NumEltsAndEltVT = getVectorLoweringShape (ResVT);
5769
5780
if (!NumEltsAndEltVT)
5770
5781
return ;
5771
5782
const auto [NumElts, EltVT] = NumEltsAndEltVT.value ();
5772
5783
5773
- LoadSDNode *LD = cast<LoadSDNode>(N);
5774
-
5775
5784
Align Alignment = LD->getAlign ();
5776
5785
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 ()));
5779
5787
if (Alignment < PrefAlign) {
5780
5788
// This load is not sufficiently aligned, so bail out and let this vector
5781
5789
// load be scalarized. Note that we may still be able to emit smaller
@@ -5806,9 +5814,10 @@ static void ReplaceLoadVector(SDNode *N, SelectionDAG &DAG,
5806
5814
break ;
5807
5815
}
5808
5816
}
5817
+ SDLoc DL (LD);
5809
5818
5810
5819
// Copy regular operands
5811
- SmallVector<SDValue, 8 > OtherOps (N ->ops ());
5820
+ SmallVector<SDValue, 8 > OtherOps (LD ->ops ());
5812
5821
5813
5822
// The select routine does not have access to the LoadSDNode instance, so
5814
5823
// pass along the extension information
0 commit comments