[clang-tools-extra] [llvm] [clang] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 16 07:38:02 PST 2023


================
@@ -31259,14 +31274,23 @@ static SDValue LowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG,
   if (!IsSeqCst && IsTypeLegal)
     return Op;
 
-  if (VT == MVT::i64 && !IsTypeLegal) {
+  if (!IsTypeLegal && !Subtarget.useSoftFloat() &&
+      !DAG.getMachineFunction().getFunction().hasFnAttribute(
+          Attribute::NoImplicitFloat)) {
+    SDValue Chain;
+    // For illegal i128 atomic_store, when AVX is enabled, we can simply emit a
+    // vector store.
+    if (VT == MVT::i128) {
+      if (Subtarget.is64Bit() && Subtarget.hasAVX()) {
+        SDValue VecVal = DAG.getBitcast(MVT::v2i64, Node->getVal());
+        Chain = DAG.getStore(Node->getChain(), dl, VecVal, Node->getBasePtr(),
+                             Node->getMemOperand());
+      }
+    }
+
     // For illegal i64 atomic_stores, we can try to use MOVQ or MOVLPS if SSE
     // is enabled.
-    bool NoImplicitFloatOps =
-        DAG.getMachineFunction().getFunction().hasFnAttribute(
-            Attribute::NoImplicitFloat);
-    if (!Subtarget.useSoftFloat() && !NoImplicitFloatOps) {
-      SDValue Chain;
+    if (VT == MVT::i64) {
       if (Subtarget.hasSSE1()) {
----------------
jyknight wrote:

This has an "else if" attached, so better not to.

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


More information about the cfe-commits mailing list