[DSE] Extending isOverwrite to support offsetted fully overlapping stores
authorMatteo Favaro <fvrmatteo@gmail.com>
Wed, 10 Mar 2021 20:07:54 +0000 (21:07 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 10 Mar 2021 20:09:33 +0000 (21:09 +0100)
commit989051d5f899c22fd2b3b4bb039b2913be0a2a4a
tree08f6e7742884739b7be2c1400da450e5c75f2c13
parent98fe9e41f7a612193ee74689961050bd4dc7c61e
[DSE] Extending isOverwrite to support offsetted fully overlapping stores

The isOverwrite function is making sure to identify if two stores
are fully overlapping and ideally we would like to identify all the
instances of OW_Complete as they'll yield possibly killable stores.
The current implementation is incapable of spotting instances where
the earlier store is offsetted compared to the later store, but
still fully overlapped. The limitation seems to lie on the
computation of the base pointers with the
GetPointerBaseWithConstantOffset API that often yields different
base pointers even if the stores are guaranteed to partially overlap
(e.g. the alias analysis is returning AliasResult::PartialAlias).

The patch relies on the offsets computed and cached by BatchAAResults
(available after D93529) to determine if the offsetted overlapping
is OW_Complete.

Differential Revision: https://reviews.llvm.org/D97676
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/offsetted-overlapping-stores.ll [new file with mode: 0644]