[llvm] Add known and demanded bits support for zext nneg (PR #70858)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 11:39:31 PDT 2023


================
@@ -1103,6 +1103,9 @@ static void computeKnownBitsFromOperator(const Operator *I,
     assert(SrcBitWidth && "SrcBitWidth can't be zero");
     Known = Known.anyextOrTrunc(SrcBitWidth);
     computeKnownBits(I->getOperand(0), Known, Depth + 1, Q);
+    if (auto *Inst = dyn_cast<Instruction>(I);
+        Inst && Inst->getOpcode() == Instruction::ZExt && Inst->hasNonNeg())
+      Known.makeNonNegative();
----------------
preames wrote:

It seems like doing it this way is missing an optimization.  Be proving a conflict, haven't we proven the resulting value to be poison?  If so, why are we not taking advantage of that to fold the value to poison?  

Glancing through the code for KnownBits and SimplifyDemanded, I don't see any clear evidence of a consistent scheme being followed.  Do you know the big picture here?

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


More information about the llvm-commits mailing list