[llvm] [ValueTracking] Conservative NoSync check prevents vectorization (PR #199002)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu May 28 00:51:06 PDT 2026


================
@@ -708,18 +708,21 @@ bool llvm::willNotFreeBetween(const Instruction *Assume,
     for (const auto &[Idx, I] : enumerate(Range)) {
       if (Idx > MaxInstrsToCheckForFree)
         return false;
-      if (const auto *CB = dyn_cast<CallBase>(&I))
-        if (!CB->hasFnAttr(Attribute::NoFree))
+
+      if (I.maySynchronize())
+        return false;
+
+      auto *CB = dyn_cast<CallBase>(&I);
+      if (CB) {
+        // Non call site cases covered by the two checks above
+        if (!CB->hasFnAttr(Attribute::NoSync) ||
+            !CB->hasFnAttr(Attribute::NoFree))
           return false;
+      }
----------------
nikic wrote:

```suggestion
      if (auto *CB = dyn_cast<CallBase>(&I))
        return CB->hasFnAttr(Attribute::NoFree));
      
      if (I.maySynchronize())
        return false;
```

Per the clarification in https://github.com/llvm/llvm-project/pull/195658, for calls, just checking nofree is sufficient (no need to check nosync as well).

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


More information about the llvm-commits mailing list