[PATCH] D19821: [EarlyCSE] Optionally use MemorySSA. NFC.
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 22 15:04:20 PDT 2016
dberlin added inline comments.
================
Comment at: lib/Transforms/Scalar/EarlyCSE.cpp:537
@@ +536,3 @@
+ MemoryAccess *LaterDef =
+ MSSA->getWalker()->getClobberingMemoryAccess(LaterInst);
+ return MSSA->dominates(LaterDef, MSSA->getMemoryAccess(EarlierInst));
----------------
gberry wrote:
> dberlin wrote:
> > 1. For loads, you don't have to ask for the clobbering access. It's already optimized such that getDefiningAccess == the clobbering access
> >
> > 2. For stores, not sure if you realize this, but
> >
> > given
> > store q (lets's call this a)
> > x = load p
> > store q (let's call this b)
> >
> >
> > if you call getClobberingMemoryAccess on b, it will return a.
> >
> >
> For 1., I was not clear on whether this holds true after store removal.
>
> For 2., yeah I get this, I'm not sure what you're getting at though. The removal of this second store by EarlyCSE doesn't use MemorySSA to check for intervening loads in this change. It uses the 'LastStore' tracking to know when a store made redundant by a second store can be removed.
1. Updates have to make it hold after store removal :)
The problem is that if we don't keep this invariant up to date, it means everyone uses getClobberingAccess, which does a bunch of work to discover the load already points to the same thing.
Everyone doing that is much higher than the cost of one person updating the dominating def.
(there is one case were getClobberingAccess will give you a better answer, and that is on cases where we gave up during use optimization. I only have one testcase this occurs on. We only give up on optimizing a load if it's going to be super expensive, and you probably do *not* want to try to get better answers in that case).
As for updating when you remove stores, you should simply be able to replace any loads the store uses with getClobberingAccess(store) using RAUW.
Under the covers, removeMemoryAccess calls RAUW with the DefiningAccess.
We could change it to use getClobberingMemoryAccess for loads, and DefiningAccess for stores.
2. ah, okay.
https://reviews.llvm.org/D19821
More information about the llvm-commits
mailing list