[TargetLowering] expandUnalignedStore - cleanup EVT variables. NFCI.

Avoid duplicated EVTs and rename Store/Load VTs to avoid -Wshadow warnings.

llvm-svn: 359877
This commit is contained in:
Simon Pilgrim 2019-05-03 12:55:25 +00:00
parent b641b914a3
commit e798e3a346
1 changed files with 18 additions and 23 deletions

View File

@ -5325,17 +5325,16 @@ SDValue TargetLowering::expandUnalignedStore(StoreSDNode *ST,
EVT VT = Val.getValueType(); EVT VT = Val.getValueType();
int Alignment = ST->getAlignment(); int Alignment = ST->getAlignment();
auto &MF = DAG.getMachineFunction(); auto &MF = DAG.getMachineFunction();
EVT MemVT = ST->getMemoryVT(); EVT StoreMemVT = ST->getMemoryVT();
SDLoc dl(ST); SDLoc dl(ST);
if (MemVT.isFloatingPoint() || MemVT.isVector()) { if (StoreMemVT.isFloatingPoint() || StoreMemVT.isVector()) {
EVT intVT = EVT::getIntegerVT(*DAG.getContext(), VT.getSizeInBits()); EVT intVT = EVT::getIntegerVT(*DAG.getContext(), VT.getSizeInBits());
if (isTypeLegal(intVT)) { if (isTypeLegal(intVT)) {
if (!isOperationLegalOrCustom(ISD::STORE, intVT) && if (!isOperationLegalOrCustom(ISD::STORE, intVT) &&
MemVT.isVector()) { StoreMemVT.isVector()) {
// Scalarize the store and let the individual components be handled. // Scalarize the store and let the individual components be handled.
SDValue Result = scalarizeVectorStore(ST, DAG); SDValue Result = scalarizeVectorStore(ST, DAG);
return Result; return Result;
} }
// Expand to a bitconvert of the value to the integer type of the // Expand to a bitconvert of the value to the integer type of the
@ -5348,24 +5347,22 @@ SDValue TargetLowering::expandUnalignedStore(StoreSDNode *ST,
} }
// Do a (aligned) store to a stack slot, then copy from the stack slot // Do a (aligned) store to a stack slot, then copy from the stack slot
// to the final destination using (unaligned) integer loads and stores. // to the final destination using (unaligned) integer loads and stores.
EVT StoredVT = ST->getMemoryVT(); MVT RegVT = getRegisterType(
MVT RegVT = *DAG.getContext(),
getRegisterType(*DAG.getContext(), EVT::getIntegerVT(*DAG.getContext(), StoreMemVT.getSizeInBits()));
EVT::getIntegerVT(*DAG.getContext(),
StoredVT.getSizeInBits()));
EVT PtrVT = Ptr.getValueType(); EVT PtrVT = Ptr.getValueType();
unsigned StoredBytes = StoredVT.getStoreSize(); unsigned StoredBytes = StoreMemVT.getStoreSize();
unsigned RegBytes = RegVT.getSizeInBits() / 8; unsigned RegBytes = RegVT.getSizeInBits() / 8;
unsigned NumRegs = (StoredBytes + RegBytes - 1) / RegBytes; unsigned NumRegs = (StoredBytes + RegBytes - 1) / RegBytes;
// Make sure the stack slot is also aligned for the register type. // Make sure the stack slot is also aligned for the register type.
SDValue StackPtr = DAG.CreateStackTemporary(StoredVT, RegVT); SDValue StackPtr = DAG.CreateStackTemporary(StoreMemVT, RegVT);
auto FrameIndex = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex(); auto FrameIndex = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
// Perform the original store, only redirected to the stack slot. // Perform the original store, only redirected to the stack slot.
SDValue Store = DAG.getTruncStore( SDValue Store = DAG.getTruncStore(
Chain, dl, Val, StackPtr, Chain, dl, Val, StackPtr,
MachinePointerInfo::getFixedStack(MF, FrameIndex, 0), StoredVT); MachinePointerInfo::getFixedStack(MF, FrameIndex, 0), StoreMemVT);
EVT StackPtrVT = StackPtr.getValueType(); EVT StackPtrVT = StackPtr.getValueType();
@ -5394,17 +5391,17 @@ SDValue TargetLowering::expandUnalignedStore(StoreSDNode *ST,
// The last store may be partial. Do a truncating store. On big-endian // The last store may be partial. Do a truncating store. On big-endian
// machines this requires an extending load from the stack slot to ensure // machines this requires an extending load from the stack slot to ensure
// that the bits are in the right place. // that the bits are in the right place.
EVT MemVT = EVT::getIntegerVT(*DAG.getContext(), EVT LoadMemVT =
8 * (StoredBytes - Offset)); EVT::getIntegerVT(*DAG.getContext(), 8 * (StoredBytes - Offset));
// Load from the stack slot. // Load from the stack slot.
SDValue Load = DAG.getExtLoad( SDValue Load = DAG.getExtLoad(
ISD::EXTLOAD, dl, RegVT, Store, StackPtr, ISD::EXTLOAD, dl, RegVT, Store, StackPtr,
MachinePointerInfo::getFixedStack(MF, FrameIndex, Offset), MemVT); MachinePointerInfo::getFixedStack(MF, FrameIndex, Offset), LoadMemVT);
Stores.push_back( Stores.push_back(
DAG.getTruncStore(Load.getValue(1), dl, Load, Ptr, DAG.getTruncStore(Load.getValue(1), dl, Load, Ptr,
ST->getPointerInfo().getWithOffset(Offset), MemVT, ST->getPointerInfo().getWithOffset(Offset), LoadMemVT,
MinAlign(ST->getAlignment(), Offset), MinAlign(ST->getAlignment(), Offset),
ST->getMemOperand()->getFlags(), ST->getAAInfo())); ST->getMemOperand()->getFlags(), ST->getAAInfo()));
// The order of the stores doesn't matter - say it with a TokenFactor. // The order of the stores doesn't matter - say it with a TokenFactor.
@ -5412,18 +5409,16 @@ SDValue TargetLowering::expandUnalignedStore(StoreSDNode *ST,
return Result; return Result;
} }
assert(ST->getMemoryVT().isInteger() && assert(StoreMemVT.isInteger() && !StoreMemVT.isVector() &&
!ST->getMemoryVT().isVector() &&
"Unaligned store of unknown type."); "Unaligned store of unknown type.");
// Get the half-size VT // Get the half-size VT
EVT NewStoredVT = ST->getMemoryVT().getHalfSizedIntegerVT(*DAG.getContext()); EVT NewStoredVT = StoreMemVT.getHalfSizedIntegerVT(*DAG.getContext());
int NumBits = NewStoredVT.getSizeInBits(); int NumBits = NewStoredVT.getSizeInBits();
int IncrementSize = NumBits / 8; int IncrementSize = NumBits / 8;
// Divide the stored value in two parts. // Divide the stored value in two parts.
SDValue ShiftAmount = SDValue ShiftAmount = DAG.getConstant(
DAG.getConstant(NumBits, dl, getShiftAmountTy(Val.getValueType(), NumBits, dl, getShiftAmountTy(Val.getValueType(), DAG.getDataLayout()));
DAG.getDataLayout()));
SDValue Lo = Val; SDValue Lo = Val;
SDValue Hi = DAG.getNode(ISD::SRL, dl, VT, Val, ShiftAmount); SDValue Hi = DAG.getNode(ISD::SRL, dl, VT, Val, ShiftAmount);