@@ -722,7 +722,6 @@ SDValue AMDGPUTargetLowering::LowerLOAD(SDValue Op, SelectionDAG &DAG) const {
722
722
return SDValue ();
723
723
724
724
725
- unsigned Mask = (1 << Load->getMemoryVT ().getSizeInBits ()) - 1 ;
726
725
SDValue Ptr = DAG.getNode (ISD::SRL, DL, MVT::i32, Load->getBasePtr (),
727
726
DAG.getConstant (2 , MVT::i32));
728
727
SDValue Ret = DAG.getNode (AMDGPUISD::REGISTER_LOAD, DL, Op.getValueType (),
@@ -734,17 +733,16 @@ SDValue AMDGPUTargetLowering::LowerLOAD(SDValue Op, SelectionDAG &DAG) const {
734
733
DAG.getConstant (0x3 , MVT::i32));
735
734
SDValue ShiftAmt = DAG.getNode (ISD::SHL, DL, MVT::i32, ByteIdx,
736
735
DAG.getConstant (3 , MVT::i32));
736
+
737
737
Ret = DAG.getNode (ISD::SRL, DL, MVT::i32, Ret, ShiftAmt);
738
- Ret = DAG. getNode (ISD::AND, DL, MVT::i32, Ret,
739
- DAG. getConstant (Mask, MVT::i32) );
738
+
739
+ EVT MemEltVT = MemVT. getScalarType ( );
740
740
if (ExtType == ISD::SEXTLOAD) {
741
- SDValue SExtShift = DAG.getConstant (
742
- VT.getSizeInBits () - MemVT.getSizeInBits (), MVT::i32);
743
- Ret = DAG.getNode (ISD::SHL, DL, MVT::i32, Ret, SExtShift);
744
- Ret = DAG.getNode (ISD::SRA, DL, MVT::i32, Ret, SExtShift);
741
+ SDValue MemEltVTNode = DAG.getValueType (MemEltVT);
742
+ return DAG.getNode (ISD::SIGN_EXTEND_INREG, DL, MVT::i32, Ret, MemEltVTNode);
745
743
}
746
744
747
- return Ret;
745
+ return DAG. getZeroExtendInReg ( Ret, DL, MemEltVT) ;
748
746
}
749
747
750
748
SDValue AMDGPUTargetLowering::LowerSTORE (SDValue Op, SelectionDAG &DAG) const {
@@ -762,8 +760,9 @@ SDValue AMDGPUTargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
762
760
return SplitVectorStore (Op, DAG);
763
761
}
764
762
763
+ EVT MemVT = Store->getMemoryVT ();
765
764
if (Store->getAddressSpace () == AMDGPUAS::PRIVATE_ADDRESS &&
766
- Store-> getMemoryVT () .bitsLT (MVT::i32)) {
765
+ MemVT .bitsLT (MVT::i32)) {
767
766
unsigned Mask = 0 ;
768
767
if (Store->getMemoryVT () == MVT::i8) {
769
768
Mask = 0xff ;
@@ -781,10 +780,12 @@ SDValue AMDGPUTargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
781
780
DAG.getConstant (3 , MVT::i32));
782
781
SDValue SExtValue = DAG.getNode (ISD::SIGN_EXTEND, DL, MVT::i32,
783
782
Store->getValue ());
784
- SDValue MaskedValue = DAG.getNode (ISD::AND, DL, MVT::i32, SExtValue,
785
- DAG.getConstant (Mask, MVT::i32));
783
+
784
+ SDValue MaskedValue = DAG.getZeroExtendInReg (SExtValue, DL, MemVT);
785
+
786
786
SDValue ShiftedValue = DAG.getNode (ISD::SHL, DL, MVT::i32,
787
787
MaskedValue, ShiftAmt);
788
+
788
789
SDValue DstMask = DAG.getNode (ISD::SHL, DL, MVT::i32, DAG.getConstant (Mask, MVT::i32),
789
790
ShiftAmt);
790
791
DstMask = DAG.getNode (ISD::XOR, DL, MVT::i32, DstMask,
0 commit comments