[llvm] 97b9e84 - [GVN][NFC] Remove redundant check

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 19 17:25:37 PST 2021


Author: ksyx
Date: 2021-11-19T20:24:36-05:00
New Revision: 97b9e8438e269a999969b08d4efe20c3d71013ca

URL: https://github.com/llvm/llvm-project/commit/97b9e8438e269a999969b08d4efe20c3d71013ca
DIFF: https://github.com/llvm/llvm-project/commit/97b9e8438e269a999969b08d4efe20c3d71013ca.diff

LOG: [GVN][NFC] Remove redundant check

The if-check above deleted part guarantees that StoreOffset <= LoadOffset
and that StoreOffset + StoreSize >= LoadOffset + LoadSize, and given that
LoadOffset + LoadSize > LoadOffset when LoadSize > 0. Thus, this shows
StoreOffset + StoreSize > LoadOffset is guaranteed given LoadSize > 0,
while it could be meaningless to have a type with nonpositive size, so that
the check could be removed. The values are converted to signed types to
avoid unsigned operation with negative offsets.

Part of revision D100179
Reapply commit c35e8185d8c170c20e28956e0c9f3c1be895fefb with fixing problem
reported by mstorsjo

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 dbe3cc93e72b4..bbe6b3dc23b3e 100644
--- a/llvm/lib/Transforms/Utils/VNCoercion.cpp
+++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp
@@ -201,19 +201,7 @@ static int analyzeLoadFromClobberingWrite(Type *LoadTy, Value *LoadPtr,
   // (issue a smaller load then merge the bits in) but this seems unlikely to be
   // valuable.
   if (StoreOffset > LoadOffset ||
-      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)
+      StoreOffset + int64_t(StoreSize) < LoadOffset + int64_t(LoadSize))
     return -1;
 
   // Okay, we can do this transformation.  Return the number of bytes into the


        


More information about the llvm-commits mailing list