Previously posted to https://reviews.llvm.org/D28395 .
This will do everything that the current DSE does (except partial overwrite
tracking), but globally and sparsely (thanks to MemorySSA). Its main limitation
is that it requires every the later store of a DSE pair to post-dom the earlier.
In other words, it can't transform this:
store _ -> %x if undef: store _ -> %x else: // do nothing.
into:
if undef: store _ -> %x else: store _ -> %x
because the store inside the if-block doesn't post-dom the first one. Properly
handling this case would require a PRE approach (thanks Dan) that I'm also
currently cooking up.
So the purpose of posting this is posterity, and also to act as a back-up in
case the PRE attempt fails.
Why are the comments after the code?