forked from OSchip/llvm-project
[LegalizeDAG] Use getMemBasePlusOffset to simplify some code. Use other signature of getMemBasePlusOffset in another location. NFCI
The code was calculating an offset from a stack pointer SDValue. This is exactly what getMemBasePlusOffset does. I also replaced sizeof(int) with a hardcoded 4. We know the type we're operating on is 4 bytes. But the size of int that the source code is being compiled with isn't guaranteed to be 4 bytes. While here replace another use of getMemBasePlusOffset that was proceeded with a call to getConstant with the other signature that call getConstant internally.
This commit is contained in:
parent
45c7b3fd91
commit
13d44b2a0c
|
@ -1409,8 +1409,7 @@ SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) {
|
|||
|
||||
unsigned Offset = TypeByteSize*i;
|
||||
|
||||
SDValue Idx = DAG.getConstant(Offset, dl, FIPtr.getValueType());
|
||||
Idx = DAG.getMemBasePlusOffset(FIPtr, Idx, dl);
|
||||
SDValue Idx = DAG.getMemBasePlusOffset(FIPtr, Offset, dl);
|
||||
|
||||
// If the destination vector element type is narrower than the source
|
||||
// element type, only store the bits necessary.
|
||||
|
@ -2356,13 +2355,9 @@ SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(SDNode *Node,
|
|||
// Get the stack frame index of a 8 byte buffer.
|
||||
SDValue StackSlot = DAG.CreateStackTemporary(MVT::f64);
|
||||
|
||||
// word offset constant for Hi/Lo address computation
|
||||
SDValue WordOff = DAG.getConstant(sizeof(int), dl,
|
||||
StackSlot.getValueType());
|
||||
// set up Hi and Lo (into buffer) address based on endian
|
||||
SDValue Hi = StackSlot;
|
||||
SDValue Lo = DAG.getNode(ISD::ADD, dl, StackSlot.getValueType(),
|
||||
StackSlot, WordOff);
|
||||
SDValue Lo = DAG.getMemBasePlusOffset(StackSlot, 4, dl);
|
||||
if (DAG.getDataLayout().isLittleEndian())
|
||||
std::swap(Hi, Lo);
|
||||
|
||||
|
|
Loading…
Reference in New Issue