[llvm] [GVN] Teach GVN simple masked load/store forwarding (PR #157689)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 18 06:37:39 PDT 2025


================
@@ -2287,6 +2288,46 @@ bool GVNPass::processLoad(LoadInst *L) {
   return true;
 }
 
+// Attempt to process masked loads which have loaded from
+// masked stores with the same mask
+bool GVNPass::processMaskedLoad(IntrinsicInst *I) {
+  Value *Mask = I->getOperand(2);
+  Value *Passthrough = I->getOperand(3);
+
+  MemDepResult Dep = MD->getDependency(I);
----------------
david-arm wrote:

Looking at processLoad it seems like you need an additional check:

```
  if (!MD)
    return false;
```

Would be good to add a test for this too.

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


More information about the llvm-commits mailing list