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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 18 12:14:08 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()) {
----------------
nikic wrote:

Could you please also add a test with a non-argmemonly call that is hoisted? I guess like neg_not_argmemonly, just without the `@load`.

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


More information about the llvm-commits mailing list