-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[ValueTracking] Convert isKnownNonZero
to use SimplifyQuery
#85863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9b725ff
b80b7de
4af6856
e780f79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -645,7 +645,7 @@ LazyValueInfoImpl::solveBlockValueImpl(Value *Val, BasicBlock *BB) { | |
// instruction is placed, even if it could legally be hoisted much higher. | ||
// That is unfortunate. | ||
PointerType *PT = dyn_cast<PointerType>(BBI->getType()); | ||
if (PT && isKnownNonZero(BBI, DL)) | ||
if (PT && isKnownNonZero(BBI, /*Depth=*/0, DL)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side note: We're currently inconsistent about this, but I think it would be best if we moved all the depth parameters after SQ, because end-users of the API don't need to specify depth. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you aren't going to implement that, I will after this patch lands. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that this PR changes it so that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I don't make the llvm19 cutoff, I'll drop it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I had been slightly optimistic that this was just going to be a few days, but it sounds like it's going to be longer. In that case I will check what is easiest for us (which might be to submit that LLVM change ourselves). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created #88873 for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for making the PR :) |
||
return ValueLatticeElement::getNot(ConstantPointerNull::get(PT)); | ||
|
||
if (BBI->getType()->isIntegerTy()) { | ||
|
@@ -1863,7 +1863,8 @@ LazyValueInfo::getPredicateAt(unsigned Pred, Value *V, Constant *C, | |
Module *M = CxtI->getModule(); | ||
const DataLayout &DL = M->getDataLayout(); | ||
if (V->getType()->isPointerTy() && C->isNullValue() && | ||
isKnownNonZero(V->stripPointerCastsSameRepresentation(), DL)) { | ||
isKnownNonZero(V->stripPointerCastsSameRepresentation(), /*Depth=*/0, | ||
DL)) { | ||
if (Pred == ICmpInst::ICMP_EQ) | ||
return LazyValueInfo::False; | ||
else if (Pred == ICmpInst::ICMP_NE) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you also need to erase the old API?
computeKnownBits
has both.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason to keep the old API. It is unlikely to break LLVM downstream users' build (except some static analysis tools).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few places it makes the code simpler (i.e the cases with just DL and depth==0).