[llvm] 5ec368d - [GuardWidening] Rename 'isAvailableAt' -> 'canBeHoistedTo' (NFC)

Dmitry Makogon via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 01:31:01 PST 2023


Author: Dmitry Makogon
Date: 2023-02-28T16:30:11+07:00
New Revision: 5ec368d7f4b93e692cea184d7f9f84d695e42fd8

URL: https://github.com/llvm/llvm-project/commit/5ec368d7f4b93e692cea184d7f9f84d695e42fd8
DIFF: https://github.com/llvm/llvm-project/commit/5ec368d7f4b93e692cea184d7f9f84d695e42fd8.diff

LOG: [GuardWidening] Rename 'isAvailableAt' -> 'canBeHoistedTo' (NFC)

This better describes what this method does.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/GuardWidening.cpp b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
index 3ded658fd22f..064c7b1d0ad1 100644
--- a/llvm/lib/Transforms/Scalar/GuardWidening.cpp
+++ b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
@@ -187,16 +187,16 @@ class GuardWideningImpl {
                                      bool InvertCond);
 
   /// Helper to check if \p V can be hoisted to \p InsertPos.
-  bool isAvailableAt(const Value *V, const Instruction *InsertPos) const {
+  bool canBeHoistedTo(const Value *V, const Instruction *InsertPos) const {
     SmallPtrSet<const Instruction *, 8> Visited;
-    return isAvailableAt(V, InsertPos, Visited);
+    return canBeHoistedTo(V, InsertPos, Visited);
   }
 
-  bool isAvailableAt(const Value *V, const Instruction *InsertPos,
-                     SmallPtrSetImpl<const Instruction *> &Visited) const;
+  bool canBeHoistedTo(const Value *V, const Instruction *InsertPos,
+                      SmallPtrSetImpl<const Instruction *> &Visited) const;
 
   /// Helper to hoist \p V to \p InsertPos.  Guaranteed to succeed if \c
-  /// isAvailableAt returned true.
+  /// canBeHoistedTo returned true.
   void makeAvailableAt(Value *V, Instruction *InsertPos) const;
 
   /// Common helper used by \c widenGuard and \c isWideningCondProfitable.  Try
@@ -440,9 +440,9 @@ GuardWideningImpl::computeWideningScore(Instruction *DominatedInstr,
   }
 
   auto *WideningPoint = findInsertionPointForWideCondition(DominatingGuard);
-  if (!isAvailableAt(getCondition(DominatedInstr), WideningPoint))
+  if (!canBeHoistedTo(getCondition(DominatedInstr), WideningPoint))
     return WS_IllegalOrNegative;
-  if (!isAvailableAt(getCondition(DominatingGuard), WideningPoint))
+  if (!canBeHoistedTo(getCondition(DominatingGuard), WideningPoint))
     return WS_IllegalOrNegative;
 
   // If the guard was conditional executed, it may never be reached
@@ -483,7 +483,7 @@ GuardWideningImpl::computeWideningScore(Instruction *DominatedInstr,
   return MaybeHoistingOutOfIf() ? WS_IllegalOrNegative : WS_Neutral;
 }
 
-bool GuardWideningImpl::isAvailableAt(
+bool GuardWideningImpl::canBeHoistedTo(
     const Value *V, const Instruction *Loc,
     SmallPtrSetImpl<const Instruction *> &Visited) const {
   auto *Inst = dyn_cast<Instruction>(V);
@@ -502,7 +502,7 @@ bool GuardWideningImpl::isAvailableAt(
   assert(DT.isReachableFromEntry(Inst->getParent()) &&
          "We did a DFS from the block entry!");
   return all_of(Inst->operands(),
-                [&](Value *Op) { return isAvailableAt(Op, Loc, Visited); });
+                [&](Value *Op) { return canBeHoistedTo(Op, Loc, Visited); });
 }
 
 void GuardWideningImpl::makeAvailableAt(Value *V, Instruction *Loc) const {
@@ -511,7 +511,8 @@ void GuardWideningImpl::makeAvailableAt(Value *V, Instruction *Loc) const {
     return;
 
   assert(isSafeToSpeculativelyExecute(Inst, Loc, &AC, &DT) &&
-         !Inst->mayReadFromMemory() && "Should've checked with isAvailableAt!");
+         !Inst->mayReadFromMemory() &&
+         "Should've checked with canBeHoistedTo!");
 
   for (Value *Op : Inst->operands())
     makeAvailableAt(Op, Loc);
@@ -552,7 +553,7 @@ bool GuardWideningImpl::widenCondCommon(Value *Cond0, Value *Cond1,
           if (InsertPt) {
             ConstantInt *NewRHS =
                 ConstantInt::get(Cond0->getContext(), NewRHSAP);
-            assert(isAvailableAt(LHS, InsertPt) && "must be");
+            assert(canBeHoistedTo(LHS, InsertPt) && "must be");
             makeAvailableAt(LHS, InsertPt);
             Result = new ICmpInst(InsertPt, Pred, LHS, NewRHS, "wide.chk");
           }


        


More information about the llvm-commits mailing list