[llvm] [LLVM][LICM] Skip unrelated accesses when looking for hoist/sink conflicting instructions. (PR #195132)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 02:41:40 PDT 2026


================
@@ -2329,8 +2329,15 @@ static bool noConflictingReadWrites(Instruction *I, MemorySSA *MSSA,
     if (!Accesses)
       continue;
     for (const auto &MA : *Accesses) {
+      // Skip unrelated accesses.
+      if (const auto *MemUseOrDef = dyn_cast<MemoryUseOrDef>(&MA))
+        if (isNoModRef(BAA.getModRefInfo(I, MemUseOrDef->getMemoryInst())))
+          continue;
+
+      // Accesses are ordered. If we find one that I dominates we can stop.
       if (!Flags.getIsSink() && MSSA->dominates(IMD, &MA))
----------------
nikic wrote:

This should be checked first, as it's the much cheaper check.

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


More information about the llvm-commits mailing list