Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,23 @@ SDValue DAGTypeLegalizer::ExpandOp_NormalStore(SDNode *N, unsigned OpNo) {

StoreSDNode *St = cast<StoreSDNode>(N);
assert(!St->isAtomic() && "Atomics can not be split");
EVT ValueVT = St->getValue().getValueType();
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), ValueVT);
SDValue Chain = St->getChain();
SDValue Value = St->getValue();
SDValue Ptr = St->getBasePtr();
EVT ValueVT = Value.getValueType();
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), ValueVT);
AAMDNodes AAInfo = St->getAAInfo();

assert(NVT.isByteSized() && "Expanded type not byte sized!");
unsigned IncrementSize = NVT.getSizeInBits() / 8;

// Storing a bitcasted value, see if the original type is a legal store.
// TODO: Not necessary if we had proper topological sorting of nodes.
if (Value.getOpcode() == ISD::BITCAST &&
TLI.isOperationLegal(ISD::STORE, Value.getOperand(0).getValueType()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The state of memory instruction legality queries is bad. Does this need to worry about alignment, address space, and everything else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add a isStoreBitCastBeneficial check as well similar to what DAGCombiner::visitSTORE does - which should do a allowsMemoryAccess check?

return DAG.getStore(Chain, dl, Value.getOperand(0), Ptr,
St->getMemOperand());

SDValue Lo, Hi;
GetExpandedOp(St->getValue(), Lo, Hi);

Expand Down
Loading