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

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 2 00:14:54 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));
----------------
andjo403 wrote:

Fixed

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


More information about the llvm-commits mailing list