You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[GVN] MemorySSA for GVN: eliminate redundant loads via MemorySSA
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:
* 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.
0 commit comments