aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-08-07 07:58:10 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-08-07 07:58:10 +0000
commitdc8767a49afe43b8d4bd5d9ad7e812bb662881fc (patch)
treee951145017ee36fe612dd7a8fe942600fb40a211 /llvm/lib/Analysis/InstructionSimplify.cpp
parent4e4f4437c27744de40acb2f79e51a7617352d7b6 (diff)
downloadllvm-dc8767a49afe43b8d4bd5d9ad7e812bb662881fc.zip
llvm-dc8767a49afe43b8d4bd5d9ad7e812bb662881fc.tar.gz
llvm-dc8767a49afe43b8d4bd5d9ad7e812bb662881fc.tar.bz2
[InstSimplify] Try hard to simplify pointer comparisons
Simplify ptrtoint comparisons involving operands with different source types. llvm-svn: 277951
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 70f3ec0..69c60eb 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -3094,6 +3094,16 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
if (LHS->getType()->isPointerTy())
if (auto *C = computePointerICmp(Q.DL, Q.TLI, Q.DT, Pred, Q.CxtI, LHS, RHS))
return C;
+ if (auto *CLHS = dyn_cast<PtrToIntOperator>(LHS))
+ if (auto *CRHS = dyn_cast<PtrToIntOperator>(RHS))
+ if (Q.DL.getTypeSizeInBits(CLHS->getPointerOperandType()) ==
+ Q.DL.getTypeSizeInBits(CLHS->getType()) &&
+ Q.DL.getTypeSizeInBits(CRHS->getPointerOperandType()) ==
+ Q.DL.getTypeSizeInBits(CRHS->getType()))
+ if (auto *C = computePointerICmp(Q.DL, Q.TLI, Q.DT, Pred, Q.CxtI,
+ CLHS->getPointerOperand(),
+ CRHS->getPointerOperand()))
+ return C;
if (GetElementPtrInst *GLHS = dyn_cast<GetElementPtrInst>(LHS)) {
if (GEPOperator *GRHS = dyn_cast<GEPOperator>(RHS)) {