[llvm] [ValueTracking] Fix KnownBits conflict for calls (range vs returned) (PR #84353)

Björn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 10:23:34 PST 2024


================
@@ -1476,6 +1476,12 @@ static void computeKnownBitsFromOperator(const Operator *I,
       if (RV->getType() == I->getType()) {
         computeKnownBits(RV, Known2, Depth + 1, Q);
         Known = Known.unionWith(Known2);
----------------
bjope wrote:

I was a bit confused as well given that the code comments talks about intersect, and then the code is doing union.
But I figured that generally we could have that the range matadata says that the function returns values in the range [0, 15] while the returned arg is known to be 8. Given that we use unionWith we would derive that the call will return 8. If we use intersectWith, then we would only get the common knowledge of bits that are zero/one. So the know bits would indicate that the returned value is in the range [0, 15].

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


More information about the llvm-commits mailing list