[llvm] [LVI] Add trunc to i1 handling. (PR #124480)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 1 13:38:01 PST 2025
================
@@ -1283,6 +1285,28 @@ std::optional<ValueLatticeElement> LazyValueInfoImpl::getValueFromICmpCondition(
return ValueLatticeElement::getOverdefined();
}
+ValueLatticeElement LazyValueInfoImpl::getValueFromTrunc(Value *Val,
+ TruncInst *Trunc,
+ bool IsTrueDest) {
+ assert(Trunc->getType()->isIntOrIntVectorTy(1));
+
+ if (Trunc->getOperand(0) != Val)
+ return ValueLatticeElement::getOverdefined();
+
+ Type *Ty = Val->getType();
+
+ if (Trunc->hasNoUnsignedWrap()) {
+ if (IsTrueDest)
+ return ValueLatticeElement::get(
+ Constant::getIntegerValue(Ty, APInt(Ty->getScalarSizeInBits(), 1)));
+ return ValueLatticeElement::get(Constant::getNullValue(Ty));
----------------
nikic wrote:
You can use `ConstantInt::getBool()` here.
https://github.com/llvm/llvm-project/pull/124480
More information about the llvm-commits
mailing list