[PATCH] D116616: [InstSimplify] use knownbits to fold more udiv/urem
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 5 06:03:42 PST 2022
spatel marked an inline comment as done.
spatel added a comment.
In D116616#3221740 <https://reviews.llvm.org/D116616#3221740>, @foad wrote:
> It seems like you're using knownbits information to derive range information. It would be good to do this more universally, and in both directions.
Yes - we do have a combination analysis called "computeConstantRangeIncludingKnownBits", so that should be more powerful.
But that is currently a static helper function in ValueTracking, so it would have to be made visible, and it would be good to have more tests to show where the extra logic gives us a better result. Ok to make that a TODO item?
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:1087-1088
+ computeKnownBits(X, Q.DL, MaxRecurse, Q.AC, Q.CxtI, Q.DT);
+ Optional<bool> IsULT = KnownBits::ult(KnownX, KnownBits::makeConstant(*C));
+ if (IsULT.hasValue() && IsULT.getValue())
+ return true;
----------------
foad wrote:
> Can't you just test `if (KnownX.getMaxValue().ult(*C))`?
Yes, that's shorter and faster. Thanks!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116616/new/
https://reviews.llvm.org/D116616
More information about the llvm-commits
mailing list