[PATCH] D17933: Set MaxAtomicInlineWidth properly for i386, i486, and x86-64 cpus without cmpxchg16b.

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 3 03:09:37 PDT 2016


majnemer added a subscriber: majnemer.

================
Comment at: lib/Basic/Targets.cpp:2565-2577
@@ -2569,1 +2564,15 @@
+
+  void setAtomic() {
+    if (getTriple().getArch() == llvm::Triple::x86_64) {
+      if (HasCX16)
+        MaxAtomicInlineWidth = 128;
+      else
+        MaxAtomicInlineWidth = 64;
+    } else if (CPU >= CK_i586)
+      MaxAtomicInlineWidth = 64;
+    else if (CPU >= CK_i486)
+      MaxAtomicInlineWidth = 32;
+    else
+      MaxAtomicInlineWidth = 0;
+  }
 };
----------------
Might be easier to read if we go from increasing strength:

```
void setAtomic() {
  MaxAtomicInlineWidth = 0;
  if (CPU >= CK_i486)
    MaxAtomicInlineWidth = 32;
  if (CPU >= CK_i586)
    MaxAtomicInlineWidth = 64;
  if (getTriple().getArch() == llvm::Triple::x86_64) {
    MaxAtomicInlineWidth = 64;
    if (HasCX16)
      MaxAtomicInlineWidth = 128;
  }
}
```

Either works for me.


http://reviews.llvm.org/D17933





More information about the cfe-commits mailing list