Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 2cf43de

Browse files
committed
R600: Code cleanup.
Use sign_extend_inreg and getZeroExtendInReg instead of using the bit operations they expand into. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203988 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7aa478d commit 2cf43de

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/Target/R600/AMDGPUISelLowering.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ SDValue AMDGPUTargetLowering::LowerLOAD(SDValue Op, SelectionDAG &DAG) const {
722722
return SDValue();
723723

724724

725-
unsigned Mask = (1 << Load->getMemoryVT().getSizeInBits()) - 1;
726725
SDValue Ptr = DAG.getNode(ISD::SRL, DL, MVT::i32, Load->getBasePtr(),
727726
DAG.getConstant(2, MVT::i32));
728727
SDValue Ret = DAG.getNode(AMDGPUISD::REGISTER_LOAD, DL, Op.getValueType(),
@@ -734,17 +733,16 @@ SDValue AMDGPUTargetLowering::LowerLOAD(SDValue Op, SelectionDAG &DAG) const {
734733
DAG.getConstant(0x3, MVT::i32));
735734
SDValue ShiftAmt = DAG.getNode(ISD::SHL, DL, MVT::i32, ByteIdx,
736735
DAG.getConstant(3, MVT::i32));
736+
737737
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();
740740
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);
745743
}
746744

747-
return Ret;
745+
return DAG.getZeroExtendInReg(Ret, DL, MemEltVT);
748746
}
749747

750748
SDValue AMDGPUTargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
@@ -762,8 +760,9 @@ SDValue AMDGPUTargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
762760
return SplitVectorStore(Op, DAG);
763761
}
764762

763+
EVT MemVT = Store->getMemoryVT();
765764
if (Store->getAddressSpace() == AMDGPUAS::PRIVATE_ADDRESS &&
766-
Store->getMemoryVT().bitsLT(MVT::i32)) {
765+
MemVT.bitsLT(MVT::i32)) {
767766
unsigned Mask = 0;
768767
if (Store->getMemoryVT() == MVT::i8) {
769768
Mask = 0xff;
@@ -781,10 +780,12 @@ SDValue AMDGPUTargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
781780
DAG.getConstant(3, MVT::i32));
782781
SDValue SExtValue = DAG.getNode(ISD::SIGN_EXTEND, DL, MVT::i32,
783782
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+
786786
SDValue ShiftedValue = DAG.getNode(ISD::SHL, DL, MVT::i32,
787787
MaskedValue, ShiftAmt);
788+
788789
SDValue DstMask = DAG.getNode(ISD::SHL, DL, MVT::i32, DAG.getConstant(Mask, MVT::i32),
789790
ShiftAmt);
790791
DstMask = DAG.getNode(ISD::XOR, DL, MVT::i32, DstMask,

0 commit comments

Comments
 (0)