OSDN Git Service

[DSE] Only eliminate candidates that always store the same loc.
authorFlorian Hahn <flo@fhahn.com>
Mon, 14 Sep 2020 10:49:27 +0000 (11:49 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 14 Sep 2020 11:06:58 +0000 (12:06 +0100)
commitf715d81c9df3fb3e047a54899fc749f57c84aeb5
treea4e036568b189f5a929992ebefb98e4a1e6b1e61
parenteef30334d1daaddf8b4e465be7c0f4aa4f98e208
[DSE] Only eliminate candidates that always store the same loc.

AliasAnalysis/MemoryLocation does not account for loops. Two
MemoryLocation can be must-overwrite, even if the first one writes
multiple locations in a loop.

This patch prevents removing such stores, by only considering candidates
that are known to be loop invariant, or executed in the same BB.

Currently the invariant check is quite conservative and only considers
Alloca and Alloca-like instructions and arguments as invariant base pointers.
It also considers GEPs with all constant indices and invariant bases as
invariant.

This can be improved in the future, but the current implementation has
only minor impact on the total number of stores eliminated (25903 vs
26047 for the baseline). There are some 2-10% swings for some individual
benchmarks. In roughly half of the cases, the number of stores removed
increases actually, because we skip candidates that are unlikely to be
valid candidates early.
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll