[llvm] 400bdbc - [ConstraintElimination] Internalize function/class and delete an implied condition. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 15:06:46 PDT 2020


Author: Fangrui Song
Date: 2020-09-26T15:04:39-07:00
New Revision: 400bdbc4220bcae0589b583604ca0af74348a139

URL: https://github.com/llvm/llvm-project/commit/400bdbc4220bcae0589b583604ca0af74348a139
DIFF: https://github.com/llvm/llvm-project/commit/400bdbc4220bcae0589b583604ca0af74348a139.diff

LOG: [ConstraintElimination] Internalize function/class and delete an implied condition. NFC

Delete an implied condition (E.NumIn <= CB.NumIn)

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 8500b831fda6..a5b7f857b90c 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -37,7 +37,7 @@ DEBUG_COUNTER(EliminatedCounter, "conds-eliminated",
 
 static int64_t MaxConstraintValue = std::numeric_limits<int64_t>::max();
 
-Optional<std::pair<int64_t, Value *>> decompose(Value *V) {
+static Optional<std::pair<int64_t, Value *>> decompose(Value *V) {
   if (auto *CI = dyn_cast<ConstantInt>(V)) {
     if (CI->isNegative() || CI->uge(MaxConstraintValue))
       return {};
@@ -116,6 +116,7 @@ getConstraint(CmpInst *Cmp, DenseMap<Value *, unsigned> &Value2Index,
                        Cmp->getOperand(1), Value2Index, ShouldAdd);
 }
 
+namespace {
 /// Represents either a condition that holds on entry to a block or a basic
 /// block, with their respective Dominator DFS in and out numbers.
 struct ConstraintOrBlock {
@@ -145,6 +146,7 @@ struct StackEntry {
   StackEntry(unsigned NumIn, unsigned NumOut, CmpInst *Condition, bool IsNot)
       : NumIn(NumIn), NumOut(NumOut), Condition(Condition), IsNot(IsNot) {}
 };
+} // namespace
 
 static bool eliminateConstraints(Function &F, DominatorTree &DT) {
   bool Changed = false;
@@ -192,8 +194,8 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT) {
       LLVM_DEBUG(dbgs() << "Top of stack : " << E.NumIn << " " << E.NumOut
                         << "\n");
       LLVM_DEBUG(dbgs() << "CB: " << CB.NumIn << " " << CB.NumOut << "\n");
-      bool IsDom = CB.NumIn >= E.NumIn && CB.NumOut <= E.NumOut;
-      if (IsDom)
+      assert(E.NumIn <= CB.NumIn);
+      if (CB.NumOut <= E.NumOut)
         break;
       LLVM_DEBUG(dbgs() << "Removing " << *E.Condition << " " << E.IsNot
                         << "\n");


        


More information about the llvm-commits mailing list