[llvm] [GVN] Drop Clobber dependency if store may overwrite only the same value (PR #68322)
Sergey Kachkov via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 05:11:13 PDT 2023
================
@@ -360,11 +360,42 @@ MemoryDependenceResults::getInvariantGroupPointerDependency(LoadInst *LI,
return MemDepResult::getNonLocal();
}
+// canSkipClobberingStore - check if SI that may alias with MemLoc can be safely
+// skipped. This is possible in case if SI can only must alias or no alias with
+// MemLoc (no partial overlapping possible) and it writes the same value that
+// MemLoc contains now (it was loaded before this store and was not modified in
+// between).
+static bool canSkipClobberingStore(const StoreInst *SI,
+ const MemoryLocation &MemLoc,
+ Align MemLocAlign, BatchAAResults &BatchAA) {
+ if (!MemLoc.Size.hasValue())
+ return false;
+ if (MemoryLocation::get(SI).Size != MemLoc.Size)
+ return false;
+ if (MemLocAlign.value() < MemLoc.Size.getValue())
+ return false;
+ if (SI->getAlign() < MemLocAlign)
+ return false;
----------------
skachkov-sc wrote:
Agreed, test-suite results are slightly improved after this change
https://github.com/llvm/llvm-project/pull/68322
More information about the llvm-commits
mailing list