[llvm] [SelectionDAG] Use unaligned store/load to move AVX registers onto stack for `insertelement` (PR #82130)
Manish Kausik H via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 09:04:00 PST 2024
================
@@ -398,22 +398,24 @@ SDValue SelectionDAGLegalize::PerformInsertVectorEltInMemory(SDValue Vec,
EVT EltVT = VT.getVectorElementType();
SDValue StackPtr = DAG.CreateStackTemporary(VT);
- int SPFI = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
+ MachineMemOperand *AlignedMMO = getStackAlignedMMO(
+ StackPtr, DAG.getMachineFunction(), EltVT.isScalableVector());
// Store the vector.
- SDValue Ch = DAG.getStore(
- DAG.getEntryNode(), dl, Tmp1, StackPtr,
- MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), SPFI));
+ SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, AlignedMMO);
+
SDValue StackPtr2 = TLI.getVectorElementPointer(DAG, StackPtr, VT, Tmp3);
// Store the scalar value.
- Ch = DAG.getTruncStore(
- Ch, dl, Tmp2, StackPtr2,
- MachinePointerInfo::getUnknownStack(DAG.getMachineFunction()), EltVT);
- // Load the updated vector.
- return DAG.getLoad(VT, dl, Ch, StackPtr, MachinePointerInfo::getFixedStack(
- DAG.getMachineFunction(), SPFI));
+ Ch = DAG.getTruncStore(Ch, dl, Tmp2, StackPtr2, EltVT, AlignedMMO);
+
+ Align ElementAlignment = std::min(cast<StoreSDNode>(Ch)->getAlign(),
+ DAG.getDataLayout().getPrefTypeAlign(
+ VT.getTypeForEVT(*DAG.getContext())));
+
+ return DAG.getLoad(VT, dl, Ch, StackPtr, MachinePointerInfo(),
----------------
Nirhar wrote:
Can you please elaborate on what is it that you want to represent this way? My knowledge on this API is still limited, hence I would not have understood your intent.
https://github.com/llvm/llvm-project/pull/82130
More information about the llvm-commits
mailing list