[llvm] [ValueTracking] Implement `isKnownNonZero`/`computeKnownBits` for `llvm.vector.reduce.{add,mul}` (PR #88410)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 10:44:37 PDT 2024
================
@@ -2904,6 +2924,41 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
case Intrinsic::vector_reduce_smax:
case Intrinsic::vector_reduce_smin:
return isKnownNonZero(II->getArgOperand(0), Depth, Q);
+ // If we know the reduction doesn't overflow and all elements are
+ // non-zero, the reduction is non-zero.
+ case Intrinsic::vector_reduce_mul:
+ case Intrinsic::vector_reduce_add:
+ if (computeKnownBits(I, Depth + 1, Q).isNonZero())
+ return true;
----------------
goldsteinn wrote:
BTW, I wouldn't spend your time reviewing this unless we decide to actually try to get it in.
https://github.com/llvm/llvm-project/pull/88410
More information about the llvm-commits
mailing list