[llvm-branch-commits] [llvm] [SelectionDAG] Widen <2 x T> vector types for atomic store (PR #197618)

Simon Pilgrim via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon May 18 04:46:26 PDT 2026


================
@@ -6608,6 +6608,24 @@ static SDValue coerceLoadedValue(SDValue LdOp, EVT FirstVT, EVT WidenVT,
   return LdOp;
 }
 
+/// Inverse of coerceLoadedValue: pull a FirstVT-sized scalar/vector out of the
+/// widened value so it can be issued in a single atomic store.
+static SDValue coerceStoredValue(SDValue StVal, EVT FirstVT, EVT WidenVT,
+                                 TypeSize FirstVTWidth, SDLoc dl,
+                                 SelectionDAG &DAG) {
+  TypeSize WidenWidth = WidenVT.getSizeInBits();
+  if (!FirstVT.isVector()) {
+    unsigned NumElts =
+        WidenWidth.getFixedValue() / FirstVTWidth.getFixedValue();
+    EVT NewVecVT = EVT::getVectorVT(*DAG.getContext(), FirstVT, NumElts);
+    SDValue VecOp = DAG.getNode(ISD::BITCAST, dl, NewVecVT, StVal);
+    return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, FirstVT, VecOp,
----------------
RKSimon wrote:

```suggestion
    return DAG.getExtractVectorElt(dl, FirstVT, VecOp, 0);
```

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


More information about the llvm-branch-commits mailing list