[llvm] r290667 - [NewGVN] equals() for loads/stores is the same. Unify.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 28 05:37:18 PST 2016
Author: davide
Date: Wed Dec 28 07:37:17 2016
New Revision: 290667
URL: http://llvm.org/viewvc/llvm-project?rev=290667&view=rev
Log:
[NewGVN] equals() for loads/stores is the same. Unify.
Differential Revision: https://reviews.llvm.org/D28116
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=290667&r1=290666&r2=290667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Wed Dec 28 07:37:17 2016
@@ -350,36 +350,26 @@ char NewGVN::ID = 0;
// createGVNPass - The public interface to this file.
FunctionPass *llvm::createNewGVNPass() { return new NewGVN(); }
-bool LoadExpression::equals(const Expression &Other) const {
- if (!isa<LoadExpression>(Other) && !isa<StoreExpression>(Other))
- return false;
- if (!this->BasicExpression::equals(Other))
+template <typename T>
+static bool equalsLoadStoreHelper(const T &LHS, const Expression &RHS) {
+ if ((!isa<LoadExpression>(RHS) && !isa<StoreExpression>(RHS)) ||
+ !LHS.BasicExpression::equals(RHS))
return false;
- if (const auto *OtherL = dyn_cast<LoadExpression>(&Other)) {
- if (DefiningAccess != OtherL->getDefiningAccess())
+ if (const auto *L = dyn_cast<LoadExpression>(&RHS))
+ if (LHS.getDefiningAccess() != L->getDefiningAccess())
return false;
- } else if (const auto *OtherS = dyn_cast<StoreExpression>(&Other)) {
- if (DefiningAccess != OtherS->getDefiningAccess())
+ if (const auto *S = dyn_cast<StoreExpression>(&RHS))
+ if (LHS.getDefiningAccess() != S->getDefiningAccess())
return false;
- }
-
return true;
}
-bool StoreExpression::equals(const Expression &Other) const {
- if (!isa<LoadExpression>(Other) && !isa<StoreExpression>(Other))
- return false;
- if (!this->BasicExpression::equals(Other))
- return false;
- if (const auto *OtherL = dyn_cast<LoadExpression>(&Other)) {
- if (DefiningAccess != OtherL->getDefiningAccess())
- return false;
- } else if (const auto *OtherS = dyn_cast<StoreExpression>(&Other)) {
- if (DefiningAccess != OtherS->getDefiningAccess())
- return false;
- }
+bool LoadExpression::equals(const Expression &Other) const {
+ return equalsLoadStoreHelper(*this, Other);
+}
- return true;
+bool StoreExpression::equals(const Expression &Other) const {
+ return equalsLoadStoreHelper(*this, Other);
}
#ifndef NDEBUG
More information about the llvm-commits
mailing list