[llvm] r290697 - Update equalsStoreHelper for the fact that only one branch can be true

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 28 16:49:33 PST 2016


Author: dannyb
Date: Wed Dec 28 18:49:32 2016
New Revision: 290697

URL: http://llvm.org/viewvc/llvm-project?rev=290697&view=rev
Log:
Update equalsStoreHelper for the fact that only one branch can be true

Modified:
    llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=290697&r1=290696&r2=290697&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Wed Dec 28 18:49:32 2016
@@ -189,7 +189,7 @@ class NewGVN : public FunctionPass {
   // We could use the congruence class machinery, but the MemoryAccess's are
   // abstract memory states, so they can only ever be equivalent to each other,
   // and not to constants, etc.
-  DenseMap<MemoryAccess *, MemoryAccess *> MemoryAccessEquiv;
+  DenseMap<const MemoryAccess *, MemoryAccess *> MemoryAccessEquiv;
 
   // Expression to class mapping.
   using ExpressionClassMap = DenseMap<const Expression *, CongruenceClass *>;
@@ -351,14 +351,15 @@ FunctionPass *llvm::createNewGVNPass() {
 template <typename T>
 static bool equalsLoadStoreHelper(const T &LHS, const Expression &RHS) {
   if ((!isa<LoadExpression>(RHS) && !isa<StoreExpression>(RHS)) ||
-      !LHS.BasicExpression::equals(RHS))
+      !LHS.BasicExpression::equals(RHS)) {
     return false;
-  if (const auto *L = dyn_cast<LoadExpression>(&RHS))
+  } else if (const auto *L = dyn_cast<LoadExpression>(&RHS)) {
     if (LHS.getDefiningAccess() != L->getDefiningAccess())
       return false;
-  if (const auto *S = dyn_cast<StoreExpression>(&RHS))
+  } else if (const auto *S = dyn_cast<StoreExpression>(&RHS)) {
     if (LHS.getDefiningAccess() != S->getDefiningAccess())
       return false;
+  }
   return true;
 }
 




More information about the llvm-commits mailing list