// area, it may be possible to update LLVM's semantics accordingly and reinstate
// this optimization.
static Constant *
-computePointerICmp(const DataLayout &DL, const TargetLibraryInfo *TLI,
- const DominatorTree *DT, CmpInst::Predicate Pred,
- AssumptionCache *AC, const Instruction *CxtI,
- const InstrInfoQuery &IIQ, Value *LHS, Value *RHS) {
+computePointerICmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS,
+ const SimplifyQuery &Q) {
+ const DataLayout &DL = Q.DL;
+ const TargetLibraryInfo *TLI = Q.TLI;
+ const DominatorTree *DT = Q.DT;
+ AssumptionCache *AC = Q.AC;
+ const Instruction *CxtI = Q.CxtI;
+ const InstrInfoQuery &IIQ = Q.IIQ;
+
// First, skip past any trivial no-ops.
LHS = LHS->stripPointerCasts();
RHS = RHS->stripPointerCasts();
// Simplify comparisons of related pointers using a powerful, recursive
// GEP-walk when we have target data available..
if (LHS->getType()->isPointerTy())
- if (auto *C = computePointerICmp(Q.DL, Q.TLI, Q.DT, Pred, Q.AC, Q.CxtI,
- Q.IIQ, LHS, RHS))
+ if (auto *C = computePointerICmp(Pred, LHS, RHS, Q))
return C;
if (auto *CLHS = dyn_cast<PtrToIntOperator>(LHS))
if (auto *CRHS = dyn_cast<PtrToIntOperator>(RHS))
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.AC, Q.CxtI,
- Q.IIQ, CLHS->getPointerOperand(),
- CRHS->getPointerOperand()))
+ if (auto *C = computePointerICmp(Pred, CLHS->getPointerOperand(),
+ CRHS->getPointerOperand(), Q))
return C;
if (GetElementPtrInst *GLHS = dyn_cast<GetElementPtrInst>(LHS)) {