[llvm] [Transforms] LoopIdiomRecognize recognize strlen and wcslen (PR #108985)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 08:00:35 PDT 2024
================
@@ -1524,6 +1545,232 @@ static Value *matchCondition(BranchInst *BI, BasicBlock *LoopEntry,
return nullptr;
}
+/// Recognizes a strlen idiom by checking for loops that increment
+/// a char pointer and then subtract with the base pointer.
+///
+/// If detected, transforms the relevant code to a strlen function
+/// call, and returns true; otherwise, returns false.
+///
+/// The core idiom we are trying to detect is:
+/// \code
----------------
Meinersbur wrote:
```suggestion
/// \code{.c}
```
Could you also/instead outline the LLVM-IR that is recognized? The C code could be lowered to a lot of different LLVM instructions and it is unclear what of it is actually detected.
https://github.com/llvm/llvm-project/pull/108985
More information about the llvm-commits
mailing list