[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:38 PDT 2024
================
@@ -1507,9 +1526,11 @@ static Value *matchCondition(BranchInst *BI, BasicBlock *LoopEntry,
if (!Cond)
return nullptr;
- ConstantInt *CmpZero = dyn_cast<ConstantInt>(Cond->getOperand(1));
- if (!CmpZero || !CmpZero->isZero())
- return nullptr;
+ if (!isa<ConstantPointerNull>(Cond->getOperand(1))) {
+ ConstantInt *CmpZero = dyn_cast<ConstantInt>(Cond->getOperand(1));
+ if (!CmpZero || !CmpZero->isZero())
+ return nullptr;
+ }
----------------
Meinersbur wrote:
Consider introducting a utility function `if (!isZeroConstant(Cond->getOperand(1)))` such as https://github.com/llvm/llvm-project/blob/7de492f90dd733859f5f0dd582860ccc5899dc22/clang/lib/CodeGen/CGPointerAuth.cpp#L169.
Or: Use ScalarEvolution's `isZero`
https://github.com/llvm/llvm-project/pull/108985
More information about the llvm-commits
mailing list