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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 15:00:00 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();
----------------
nikic wrote:

This is going to cause a conflict (and downstream assertion failures) if Known is known negative. You need to reset the known one bit -- or maybe adjust the makeNonNegative() API to do that itself, as this seems like an unnecessary footgun.

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


More information about the llvm-commits mailing list