Skip to content

Commit

Permalink
Revert "[GVN][NFC] Remove redundant check"
Browse files Browse the repository at this point in the history
This reverts commit c35e818.

mstorsjo reported in the revision thread that one VNCoercion assertion
is violated and seemly in relate to this commit. As per "If a test case
that demonstrates a problem is reported in the commit thread, please
revert and investigate offline", this commit is reverted.
  • Loading branch information
ksyx committed Nov 15, 2021
1 parent 6fb5bed commit 72b5138
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions llvm/lib/Transforms/Utils/VNCoercion.cpp
Expand Up @@ -204,6 +204,18 @@ static int analyzeLoadFromClobberingWrite(Type *LoadTy, Value *LoadPtr,
StoreOffset + StoreSize < LoadOffset + LoadSize)
return -1;

// If the load and store are to the exact same address, they should have been
// a must alias. AA must have gotten confused.
// FIXME: Study to see if/when this happens. One case is forwarding a memset
// to a load from the base of the memset.

// If the load and store don't overlap at all, the store doesn't provide
// anything to the load. In this case, they really don't alias at all, AA
// must have gotten confused. The if statement above ensure the condition
// that StoreOffset <= LoadOffset.
if (StoreOffset + int64_t(StoreSize) <= LoadOffset)
return -1;

// Okay, we can do this transformation. Return the number of bytes into the
// store that the load is.
return LoadOffset - StoreOffset;
Expand Down

0 comments on commit 72b5138

Please sign in to comment.