[llvm] [LICM] Hoisting writeonly calls (PR #143799)

Jiachen Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 18 13:55:20 PDT 2025


================
@@ -1258,8 +1261,16 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
         return true;
     }
 
-    // FIXME: This should use mod/ref information to see if we can hoist or
-    // sink the call.
+    if (Behavior.onlyWritesMemory()) {
+      // If it's the only memory access then there is nothing
+      // stopping us from hoisting it.
+      if (isOnlyMemoryAccess(CI, CurLoop, MSSAU))
+        return true;
+
+      if (Behavior.onlyAccessesArgPointees()) {
----------------
WanderingAura wrote:

Sure, done.

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


More information about the llvm-commits mailing list