[llvm] [ValueTracking] Add support for `trunc nuw/nsw` in isKnowNonZero (PR #89643)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 04:51:05 PDT 2024


================
@@ -2632,6 +2632,13 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
             Q.DL.getTypeSizeInBits(I->getType()).getFixedValue())
       return isKnownNonZero(I->getOperand(0), Q, Depth);
     break;
+  case Instruction::Trunc: {
+    auto *TI = cast<TruncInst>(I);
----------------
nikic wrote:

This probably needs to be dyn_cast, as trunc can occur in constant expressions.

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


More information about the llvm-commits mailing list