[llvm] 4b19ccc - [PredicateInfo] Fold PredicateWithCondition into PredicateBase (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 18 08:22:35 PDT 2020
Author: Florian Hahn
Date: 2020-07-18T16:21:56+01:00
New Revision: 4b19cccbb5d8d77750da96cef2daefa6c28b0e37
URL: https://github.com/llvm/llvm-project/commit/4b19cccbb5d8d77750da96cef2daefa6c28b0e37
DIFF: https://github.com/llvm/llvm-project/commit/4b19cccbb5d8d77750da96cef2daefa6c28b0e37.diff
LOG: [PredicateInfo] Fold PredicateWithCondition into PredicateBase (NFC).
Each concrete instance of a predicate has a condition (also noted in the
original PredicateBase comment) and to me it seems like there is no
clear benefit of having both PredicateBase and PredicateWithCondition
and they can be folded together.
Reviewers: nikic, efriedma
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D84089
Added:
Modified:
llvm/include/llvm/Transforms/Utils/PredicateInfo.h
llvm/lib/Transforms/Scalar/NewGVN.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Utils/PredicateInfo.h b/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
index 657b97c67a8b..cdac4142555d 100644
--- a/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
+++ b/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
@@ -83,37 +83,31 @@ class PredicateBase : public ilist_node<PredicateBase> {
// predicates, this is
diff erent to OriginalOp which refers to the initial
// operand.
Value *RenamedOp;
+ // The condition associated with this predicate.
+ Value *Condition;
+
PredicateBase(const PredicateBase &) = delete;
PredicateBase &operator=(const PredicateBase &) = delete;
PredicateBase() = delete;
virtual ~PredicateBase() = default;
-
-protected:
- PredicateBase(PredicateType PT, Value *Op) : Type(PT), OriginalOp(Op) {}
-};
-
-class PredicateWithCondition : public PredicateBase {
-public:
- Value *Condition;
static bool classof(const PredicateBase *PB) {
return PB->Type == PT_Assume || PB->Type == PT_Branch ||
PB->Type == PT_Switch;
}
protected:
- PredicateWithCondition(PredicateType PT, Value *Op, Value *Condition)
- : PredicateBase(PT, Op), Condition(Condition) {}
+ PredicateBase(PredicateType PT, Value *Op, Value *Condition)
+ : Type(PT), OriginalOp(Op), Condition(Condition) {}
};
// Provides predicate information for assumes. Since assumes are always true,
// we simply provide the assume instruction, so you can tell your relative
// position to it.
-class PredicateAssume : public PredicateWithCondition {
+class PredicateAssume : public PredicateBase {
public:
IntrinsicInst *AssumeInst;
PredicateAssume(Value *Op, IntrinsicInst *AssumeInst, Value *Condition)
- : PredicateWithCondition(PT_Assume, Op, Condition),
- AssumeInst(AssumeInst) {}
+ : PredicateBase(PT_Assume, Op, Condition), AssumeInst(AssumeInst) {}
PredicateAssume() = delete;
static bool classof(const PredicateBase *PB) {
return PB->Type == PT_Assume;
@@ -123,7 +117,7 @@ class PredicateAssume : public PredicateWithCondition {
// Mixin class for edge predicates. The FROM block is the block where the
// predicate originates, and the TO block is the block where the predicate is
// valid.
-class PredicateWithEdge : public PredicateWithCondition {
+class PredicateWithEdge : public PredicateBase {
public:
BasicBlock *From;
BasicBlock *To;
@@ -135,7 +129,7 @@ class PredicateWithEdge : public PredicateWithCondition {
protected:
PredicateWithEdge(PredicateType PType, Value *Op, BasicBlock *From,
BasicBlock *To, Value *Cond)
- : PredicateWithCondition(PType, Op, Cond), From(From), To(To) {}
+ : PredicateBase(PType, Op, Cond), From(From), To(To) {}
};
// Provides predicate information for branches.
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 0ed1773373a7..45d01cc1b584 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1539,12 +1539,8 @@ NewGVN::performSymbolicPredicateInfoEvaluation(Instruction *I) const {
LLVM_DEBUG(dbgs() << "Found predicate info from instruction !\n");
- auto *PWC = dyn_cast<PredicateWithCondition>(PI);
- if (!PWC)
- return nullptr;
-
auto *CopyOf = I->getOperand(0);
- auto *Cond = PWC->Condition;
+ auto *Cond = PI->Condition;
// If this a copy of the condition, it must be either true or false depending
// on the predicate info type and edge.
More information about the llvm-commits
mailing list