-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[InstSimplify] Remove redundant icmp+ptrtoint fold #171807
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
Conversation
There is a generic fold for recursively calling simplifyICmpInst with the ptrtoint cast stripped: https://github.com/llvm/llvm-project/blob/9b6b52b534ba592d7d6b5863e3d9a240119a74d9/llvm/lib/Analysis/InstructionSimplify.cpp#L3850-L3867 As such, we shouldn't have to explicitly do this for the computePointerICmp() fold. This is not strictly NFC because the recursion limit applies to the generic fold, though I wouldn't expect this to matter in practice.
|
@llvm/pr-subscribers-llvm-analysis Author: Nikita Popov (nikic) ChangesThere is a generic fold for recursively calling simplifyICmpInst with the ptrtoint cast stripped: llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp Lines 3850 to 3867 in 9b6b52b
As such, we shouldn't have to explicitly do this for the computePointerICmp() fold. This is not strictly NFC because the recursion limit applies to the generic fold, though I wouldn't expect this to matter in practice. Full diff: https://github.com/llvm/llvm-project/pull/171807.diff 1 Files Affected:
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 1d82515cd84f9..63930617071f3 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4077,14 +4077,6 @@ static Value *simplifyICmpInst(CmpPredicate Pred, Value *LHS, Value *RHS,
if (LHS->getType()->isPointerTy())
if (auto *C = computePointerICmp(Pred, LHS, RHS, Q))
return C;
- if (auto *CLHS = dyn_cast<PtrToIntOperator>(LHS))
- if (auto *CRHS = dyn_cast<PtrToIntOperator>(RHS))
- if (CLHS->getPointerOperandType() == CRHS->getPointerOperandType() &&
- Q.DL.getTypeSizeInBits(CLHS->getPointerOperandType()) ==
- Q.DL.getTypeSizeInBits(CLHS->getType()))
- if (auto *C = computePointerICmp(Pred, CLHS->getPointerOperand(),
- CRHS->getPointerOperand(), Q))
- return C;
// If the comparison is with the result of a select instruction, check whether
// comparing with either branch of the select always yields the same value.
|
|
No changes on llvm-opt-benchmark. |
There is a generic fold for recursively calling simplifyICmpInst with the ptrtoint cast stripped: https://github.com/llvm/llvm-project/blob/9b6b52b534ba592d7d6b5863e3d9a240119a74d9/llvm/lib/Analysis/InstructionSimplify.cpp#L3850-L3867 As such, we shouldn't have to explicitly do this for the computePointerICmp() fold. This is not strictly NFC because the recursion limit applies to the generic fold, though I wouldn't expect this to matter in practice.
There is a generic fold for recursively calling simplifyICmpInst with the ptrtoint cast stripped:
llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp
Lines 3850 to 3867 in 9b6b52b
As such, we shouldn't have to explicitly do this for the computePointerICmp() fold.
This is not strictly NFC because the recursion limit applies to the generic fold, though I wouldn't expect this to matter in practice.