[llvm] [SelectionDAG] Use unaligned store to legalize `EXTRACT_VECTOR_ELT` type (PR #98176)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 13 21:35:16 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);
----------------
phoebewang wrote:
The changes in lit test are functionally correct, but I'm not sure if we prefer to align them or not.
Revisit the original change, I think we also realigned the stack in the `foo2`, but it's not used. I guess some later optimizations may schedule the order of mov instructions. So that approach is a bit suboptimal to me.
@RKSimon which solution do you prefer?
https://github.com/llvm/llvm-project/pull/98176
More information about the llvm-commits
mailing list