[llvm] [ValueTracking] Conservative nosync check prevents vectorization (PR #181345)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 23 06:52:38 PST 2026


================
@@ -704,23 +704,37 @@ bool llvm::isValidAssumeForContext(const Instruction *Inv,
 
 bool llvm::willNotFreeBetween(const Instruction *Assume,
                               const Instruction *CtxI) {
-  // Helper to check if there are any calls in the range that may free memory.
-  auto hasNoFreeCalls = [](auto Range) {
+  // Helper to make sure the current function cannot arrange for
+  // another thread to free on its behalf and to check if there
+  // are any calls in the range that may free memory.
+  auto hasNoSyncOrFreeCall = [](auto Range) {
     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.isVolatile()) {
----------------
nikic wrote:

Omit braces for single-line if.

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


More information about the llvm-commits mailing list