Skip to content

Commit 18f19f6

Browse files
committed
resolve commens: update function signature to represent the case of simplifying icmp guarding recursive function
1 parent c5003a6 commit 18f19f6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
447447
bool canFoldInboundsGEP(GetElementPtrInst &I);
448448
bool accumulateGEPOffset(GEPOperator &GEP, APInt &Offset);
449449
bool simplifyCallSite(Function *F, CallBase &Call);
450-
bool simplifyCmpInst(Function *F, CmpInst &Cmp);
450+
bool simplifyCmpInstForRecCall(CmpInst &Cmp);
451451
bool simplifyInstruction(Instruction &I);
452452
bool simplifyIntrinsicCallIsConstant(CallBase &CB);
453453
bool simplifyIntrinsicCallObjectSize(CallBase &CB);
@@ -1681,13 +1681,14 @@ bool CallAnalyzer::visitGetElementPtr(GetElementPtrInst &I) {
16811681
}
16821682

16831683
// Simplify \p Cmp if RHS is const and we can ValueTrack LHS.
1684-
// This handles the case when the Cmp instruction is guarding a recursive call
1684+
// This handles the case only when the Cmp instruction is guarding a recursive call
16851685
// that will cause the Cmp to fail/succeed for the recursive call.
1686-
bool CallAnalyzer::simplifyCmpInst(Function *F, CmpInst &Cmp) {
1686+
bool CallAnalyzer::simplifyCmpInstForRecCall(CmpInst &Cmp) {
16871687
// Bail out if LHS is not a function argument or RHS is NOT const:
16881688
if (!isa<Argument>(Cmp.getOperand(0)) || !isa<Constant>(Cmp.getOperand(1)))
16891689
return false;
16901690
auto *CmpOp = Cmp.getOperand(0);
1691+
Function *F = Cmp.getFunction();
16911692
// Iterate over the users of the function to check if it's a recursive
16921693
// function:
16931694
for (auto *U : F->users()) {
@@ -2134,7 +2135,7 @@ bool CallAnalyzer::visitCmpInst(CmpInst &I) {
21342135
return true;
21352136

21362137
// Try to handle comparison that can be simplified using ValueTracking.
2137-
if (simplifyCmpInst(I.getFunction(), I))
2138+
if (simplifyCmpInstForRecCall(I))
21382139
return true;
21392140

21402141
if (I.getOpcode() == Instruction::FCmp)

0 commit comments

Comments
 (0)