[llvm] [LVI] Add trunc to i1 handling. (PR #124480)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 14:51:14 PST 2025


================
@@ -1283,6 +1285,20 @@ std::optional<ValueLatticeElement> LazyValueInfoImpl::getValueFromICmpCondition(
   return ValueLatticeElement::getOverdefined();
 }
 
+std::optional<ValueLatticeElement>
+LazyValueInfoImpl::getValueFromTrunc(Value *Val, TruncInst *Trunc,
+                                     bool IsTrueDest) {
+  assert(Trunc->getType()->isIntegerTy(1));
+
+  Type *Ty = Val->getType();
+  if (!Ty->isIntegerTy() || Trunc->getOperand(0) != Val)
+    return ValueLatticeElement::getOverdefined();
+
+  if (IsTrueDest)
+    return ValueLatticeElement::getNot(Constant::getNullValue(Ty));
+  return ValueLatticeElement::getNot(Constant::getAllOnesValue(Ty));
----------------
andjo403 wrote:

added handling for nuw and update the proof

https://github.com/llvm/llvm-project/pull/124480


More information about the llvm-commits mailing list