[llvm] [Analysis]: Allow inlining recursive call IF recursion depth is 1. (PR #119677)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 31 03:53:22 PDT 2025
================
@@ -1666,6 +1670,78 @@ bool CallAnalyzer::visitGetElementPtr(GetElementPtrInst &I) {
return isGEPFree(I);
}
+/// Simplify \p Cmp if RHS is const and we can ValueTrack LHS,
+// This handles the case when the Cmp instruction is guarded a recursive call
+// that will cause the Cmp to fail/succeed for the next iteration.
+bool CallAnalyzer::simplifyCmpInst(Function *F, CmpInst &Cmp) {
+ // Bail out if the RHS is NOT const:
+ if (!isa<Constant>(Cmp.getOperand(1)))
----------------
davemgreen wrote:
Can we check here that Cmp.getOperand(0) is a function argument? It is checked below too but this will allow it to early exit for a lot of icmp's.
https://github.com/llvm/llvm-project/pull/119677
More information about the llvm-commits
mailing list