[all-commits] [llvm/llvm-project] 0a758f: [GVN] MemorySSA for GVN: eliminate redundant loads...
Antonio Frighetto via All-commits
all-commits at lists.llvm.org
Tue Jun 2 01:24:04 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0a758f9356138e327134a9aea2d760a50c49a419
https://github.com/llvm/llvm-project/commit/0a758f9356138e327134a9aea2d760a50c49a419
Author: Antonio Frighetto <me at antoniofrighetto.com>
Date: 2026-06-02 (Tue, 02 Jun 2026)
Changed paths:
M llvm/include/llvm/Transforms/Scalar/GVN.h
M llvm/lib/Transforms/Scalar/GVN.cpp
M llvm/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll
M llvm/test/Transforms/GVN/PRE/load-metadata.ll
M llvm/test/Transforms/GVN/PRE/lpre-call-wrap.ll
M llvm/test/Transforms/GVN/PRE/phi-translate-2.ll
M llvm/test/Transforms/GVN/PRE/phi-translate-add.ll
M llvm/test/Transforms/GVN/PRE/phi-translate.ll
M llvm/test/Transforms/GVN/PRE/pre-after-rle.ll
M llvm/test/Transforms/GVN/PRE/pre-aliasning-path.ll
M llvm/test/Transforms/GVN/PRE/pre-load-combine-metadata.ll
M llvm/test/Transforms/GVN/PRE/pre-load-dbg.ll
M llvm/test/Transforms/GVN/PRE/pre-load-guards.ll
M llvm/test/Transforms/GVN/PRE/pre-load-implicit-cf-updates.ll
M llvm/test/Transforms/GVN/PRE/pre-load.ll
M llvm/test/Transforms/GVN/PRE/pre-single-pred.ll
M llvm/test/Transforms/GVN/PRE/preserve-tbaa.ll
M llvm/test/Transforms/GVN/PRE/rle-addrspace-cast.ll
M llvm/test/Transforms/GVN/PRE/rle-semidominated.ll
M llvm/test/Transforms/GVN/PRE/rle.ll
M llvm/test/Transforms/GVN/nonescaping.ll
M llvm/test/Transforms/GVN/pr14166.ll
M llvm/test/Transforms/GVN/readattrs.ll
M llvm/test/Transforms/GVN/setjmp.ll
M llvm/test/Transforms/GVN/tbaa.ll
M llvm/test/Transforms/GVN/vscale.ll
Log Message:
-----------
[GVN] MemorySSA for GVN: eliminate redundant loads via MemorySSA (#152859)
Introduce the main algorithm performing redundant load elimination via
MemorySSA in GVN. The entry point is `findReachingValuesForLoad`, which,
given as input a possibly redundant load `L`, it attempts to provide as
output a set of reaching memory values (`ReachingMemVal`), i.e., which
values (defs or equivalent reads) can reach `L` along at least one path
where that memory location is not modified meanwhile (if non-local, PRE
will establish whether the load may be eliminated).
Specifically, a reaching value may be of the following descriptor kind
(`DepKind`):
* Def: found a new instruction that produces exactly the bits the load
would read. For example, a must-alias store (which defines the load
memory location), or a must-alias read (exactly reads the same memory
location, found, e.g., after a phi-translation fixup);
* Clobber: found a write that clobbers a superset of the bits the load
would read. For example, a memset call over a memory region, whose value
read overlaps such a region (and may be forwarded to the load), or a
generic call clobbering the load that cannot be reused;
* Other: a precise instruction could not be found, but know the block
where the dependency exists (e.g., a memory location already live at
function entry).
We start off by looking for the users of the defining memory access of
the given load within the same block, searching for local dependencies.
We may need to iteratively follow the use-def chain of the defining
memory access to find the actual clobbering access, while staying within
the scope of the load. If an actual local def/clobber (or liveOnEntry)
is found, we are done and return that one. Otherwise, we move visiting
the predecessors of the load's block, considering the incoming value
from the MemoryPhi as a potential clobbering access. Hence, we search
for dependencies within the predecessor block itself. If the new
potential clobbering access is a MemoryPhi, we continue visiting the
transitive closure of the predecessor, recording its new potential
clobbering access. In this phase, as we are exploring non-local
definitions, the load itself may be considered a must-alias def as well
when being examined from a backedge path.
Co-authored-by: Momchil Velikov <momchil.velikov at arm.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list