[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
Fri Jul 12 08:49:53 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:

Sorry! I thought your case covers some extra conditions that I didn't exactly understand. I've reduced my patch to only your suggestion. A follow up question: Could this patch https://github.com/llvm/llvm-project/commit/a6614ec5b7c1dbfc4b847884c5de780cf75e8e9c also be rewritten in the form suggested by you ?

https://github.com/llvm/llvm-project/pull/98176


More information about the llvm-commits mailing list