[llvm] [llvm][ConstraintElimination]Insert ConditionFact into loop header in case of monotonic induction variables (PR #112080)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 11 22:40:48 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 47e6d1816251e90b3d589710c5203a92c6015a7c 3a5592a34a49d384a0dd5b7fc230cd3475bfee38 --extensions cpp -- llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 56cc26093c..b91844890e 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -198,7 +198,7 @@ struct State {
void addInfoForInductions(BasicBlock &BB);
void addConditionFactsIntoLoopHeader(BasicBlock &BB);
-
+
/// Returns true if we can add a known condition from BB to its successor
/// block Succ.
bool canAddSuccessor(BasicBlock &BB, BasicBlock *Succ) const {
@@ -910,8 +910,9 @@ void State::addConditionFactsIntoLoopHeader(BasicBlock &BB) {
if (!L || L->getHeader() != &BB)
return;
DomTreeNode *DTN = DT.getNode(&BB);
- for(PHINode &PN :L->getHeader()->phis()){
- if(PN.getNumIncomingValues() != 2 || PN.getParent() != &BB || !SE.isSCEVable(PN.getType()))
+ for (PHINode &PN : L->getHeader()->phis()) {
+ if (PN.getNumIncomingValues() != 2 || PN.getParent() != &BB ||
+ !SE.isSCEVable(PN.getType()))
continue;
auto *AR = dyn_cast_or_null<SCEVAddRecExpr>(SE.getSCEV(&PN));
BasicBlock *LoopPred = L->getLoopPredecessor();
@@ -927,31 +928,31 @@ void State::addConditionFactsIntoLoopHeader(BasicBlock &BB) {
}
auto IncUnsigned = SE.getMonotonicPredicateType(AR, CmpInst::ICMP_UGT);
auto IncSigned = SE.getMonotonicPredicateType(AR, CmpInst::ICMP_SGT);
-
- // Monotonically Increasing
+
+ // Monotonically Increasing
bool MonotonicallyIncreasingUnsigned =
- IncUnsigned && *IncUnsigned == ScalarEvolution::MonotonicallyIncreasing;
+ IncUnsigned && *IncUnsigned == ScalarEvolution::MonotonicallyIncreasing;
bool MonotonicallyIncreasingSigned =
IncSigned && *IncSigned == ScalarEvolution::MonotonicallyIncreasing;
if (MonotonicallyIncreasingUnsigned)
- WorkList.push_back(
- FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_UGE, &PN, StartValue));
+ WorkList.push_back(FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_UGE,
+ &PN, StartValue));
if (MonotonicallyIncreasingSigned)
- WorkList.push_back(
- FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_SGE, &PN, StartValue));
+ WorkList.push_back(FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_SGE,
+ &PN, StartValue));
// Monotonically Decreasing
bool MonotonicallyDecreasingUnsigned =
- IncUnsigned && *IncUnsigned == ScalarEvolution::MonotonicallyDecreasing;
+ IncUnsigned && *IncUnsigned == ScalarEvolution::MonotonicallyDecreasing;
bool MonotonicallyDecreasingSigned =
IncSigned && *IncSigned == ScalarEvolution::MonotonicallyDecreasing;
- if(MonotonicallyDecreasingUnsigned)
- WorkList.push_back(
- FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_ULE, &PN, StartValue));
- if(MonotonicallyDecreasingSigned)
- WorkList.push_back(
- FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_SLE, &PN, StartValue));
- }
+ if (MonotonicallyDecreasingUnsigned)
+ WorkList.push_back(FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_ULE,
+ &PN, StartValue));
+ if (MonotonicallyDecreasingSigned)
+ WorkList.push_back(FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_SLE,
+ &PN, StartValue));
+ }
}
void State::addInfoForInductions(BasicBlock &BB) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/112080
More information about the llvm-commits
mailing list