diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index f7b656d88dfa0..fe298fd8006a8 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2486,10 +2486,15 @@ static Value *ExtractEquivalentCondition(Value *V, CmpInst::Predicate Pred, // 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(); @@ -3651,8 +3656,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, // 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(LHS)) if (auto *CRHS = dyn_cast(RHS)) @@ -3660,9 +3664,8 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *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(LHS)) {