[PATCH] D140796: [ValueTracking] Improve ComputeNumSignBits to handle Trunc

Owen Anderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 2 21:09:29 PST 2023


resistor added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:3334
+
       break;
+    }
----------------
nikic wrote:
> resistor wrote:
> > nikic wrote:
> > > return 1 here, we don't want to fall through to computeKnownBits (the ComptueNumSignBits will have already used it if possible).
> > I don't think that's the case? We invoked `ComputeNumSignBits` on the input to the trunc, so we haven't yet had an opportunity to use `computeKnownBits` results for the output.
> Hm, I guess you are right. If the truncated part doesn't have sign bits and the part directly following has more than one known zero/one bits, then the computeKnownBits() call is still useful.
> 
> Do we already have a test that fails if it is removed?
No test currently fails, so I've gone ahead and changed it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140796/new/

https://reviews.llvm.org/D140796



More information about the llvm-commits mailing list