[PATCH] D16908: [ValueTracking] Use Constant::isZeroValue() in isKnownZero()

Nick Lewycky via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 5 10:29:42 PST 2016

nlewycky added a subscriber: nlewycky.
nlewycky requested changes to this revision.
nlewycky added a reviewer: nlewycky.
nlewycky added a comment.
This revision now requires changes to proceed.

What about a ConstantExpr like "and(ptrtoint(@global), 32)"? We don't know the 5th bit of the address of @global, so C->isZeroValue() returns false (since we don't know it's zero), but isKnownNonZero must also return false (since we don't know it's non-zero). With your patch, we would incorrectly return true.

You are replacing "is known to be non-zero" with "is not known to be zero" which are not quite the same thing for all Constants. Please send out a patch which adds a testcase that would fail if someone were to propose this change in the future.


More information about the llvm-commits mailing list