[llvm] [SelectionDAG] Use unaligned store to legalize `EXTRACT_VECTOR_ELT` type (PR #98176)
Manish Kausik H via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 04:06:14 PDT 2024
================
@@ -3531,14 +3548,14 @@ SDValue DAGTypeLegalizer::SplitVecOp_EXTRACT_VECTOR_ELT(SDNode *N) {
// Store the vector to the stack.
// In cases where the vector is illegal it will be broken down into parts
// and stored in parts - we should use the alignment for the smallest part.
- Align SmallestAlign = DAG.getReducedAlign(VecVT, /*UseABI=*/false);
+ Align SmallestAlign =
+ std::min(DAG.getSubtarget().getFrameLowering()->getStackAlign(),
+ DAG.getReducedAlign(VecVT, /*UseABI=*/false));
SDValue StackPtr =
DAG.CreateStackTemporary(VecVT.getStoreSize(), SmallestAlign);
- auto &MF = DAG.getMachineFunction();
- auto FrameIndex = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
- auto PtrInfo = MachinePointerInfo::getFixedStack(MF, FrameIndex);
- SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, PtrInfo,
- SmallestAlign);
+ MachineMemOperand *StoreMMO = getStackAlignedMMO(
+ StackPtr, DAG.getMachineFunction(), VecVT.isScalableVector());
+ SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, StoreMMO);
----------------
Nirhar wrote:
If we consider modifying `SelectionDAG::getReducedAlign` I see two locations where we can teach it to consider the Stack alignment:
1. Teach `TLI::getVectorTypeBreakdown` to clamp down to Stack Alignment. I see that we dont consider Stack Alignment inside the function.
https://github.com/llvm/llvm-project/blob/462d084241616627be1ac2b967a7fcba9b0facfe/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L2479
2. [My Preference] Modify these lines in `getReducedAlign`:
https://github.com/llvm/llvm-project/blob/462d084241616627be1ac2b967a7fcba9b0facfe/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L2482-L2487
and clamp down RedAlign2 to StackAlign if it exceeds it.
Which one is a better solution?
https://github.com/llvm/llvm-project/pull/98176
More information about the llvm-commits
mailing list