[llvm] [LVI] Learn value ranges from ctpop results (PR #121945)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 07:40:48 PST 2025
================
@@ -1159,6 +1159,28 @@ getRangeViaSLT(CmpInst::Predicate Pred, APInt RHS,
return std::nullopt;
}
+/// Get value range for a "ctpop(Val) Pred RHS" condition.
+static ValueLatticeElement getValueFromICmpCtpop(ICmpInst::Predicate Pred,
+ Value *RHS) {
+ unsigned BitWidth = RHS->getType()->getPrimitiveSizeInBits();
+
+ auto RHSConst = dyn_cast<ConstantInt>(RHS);
+ if (!RHSConst)
+ return ValueLatticeElement::getOverdefined();
+
+ auto &RHSVal = RHSConst->getValue();
----------------
nikic wrote:
```suggestion
const APInt &RHSVal = RHSConst->getValue();
```
Or just drop this variable.
https://github.com/llvm/llvm-project/pull/121945
More information about the llvm-commits
mailing list