[llvm] 72b5138 - Revert "[GVN][NFC] Remove redundant check"

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 15 06:15:12 PST 2021


Author: ksyx
Date: 2021-11-15T09:14:13-05:00
New Revision: 72b5138d37d7ec799301e29e9c1eaaa1630be161

URL: https://github.com/llvm/llvm-project/commit/72b5138d37d7ec799301e29e9c1eaaa1630be161
DIFF: https://github.com/llvm/llvm-project/commit/72b5138d37d7ec799301e29e9c1eaaa1630be161.diff

LOG: Revert "[GVN][NFC] Remove redundant check"

This reverts commit c35e8185d8c170c20e28956e0c9f3c1be895fefb.

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.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/VNCoercion.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/VNCoercion.cpp b/llvm/lib/Transforms/Utils/VNCoercion.cpp
index 9984b83c3ff0..dbe3cc93e72b 100644
--- a/llvm/lib/Transforms/Utils/VNCoercion.cpp
+++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp
@@ -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;


        


More information about the llvm-commits mailing list