diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h index a04562dc874be..f353eec8c89bb 100644 --- a/llvm/include/llvm/Analysis/ValueTracking.h +++ b/llvm/include/llvm/Analysis/ValueTracking.h @@ -94,11 +94,10 @@ void computeKnownBitsFromContext(const Value *V, KnownBits &Known, unsigned Depth, const SimplifyQuery &Q); /// Using KnownBits LHS/RHS produce the known bits for logic op (and/xor/or). -KnownBits analyzeKnownBitsFromAndXorOr( - const Operator *I, const KnownBits &KnownLHS, const KnownBits &KnownRHS, - unsigned Depth, const DataLayout &DL, AssumptionCache *AC = nullptr, - const Instruction *CxtI = nullptr, const DominatorTree *DT = nullptr, - bool UseInstrInfo = true); +KnownBits analyzeKnownBitsFromAndXorOr(const Operator *I, + const KnownBits &KnownLHS, + const KnownBits &KnownRHS, + unsigned Depth, const SimplifyQuery &SQ); /// Return true if LHS and RHS have no common bits set. bool haveNoCommonBitsSet(const WithCache &LHSCache, diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 71884dd0fbd55..250ce739ea514 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -868,17 +868,17 @@ getKnownBitsFromAndXorOr(const Operator *I, const APInt &DemandedElts, } // Public so this can be used in `SimplifyDemandedUseBits`. -KnownBits llvm::analyzeKnownBitsFromAndXorOr( - const Operator *I, const KnownBits &KnownLHS, const KnownBits &KnownRHS, - unsigned Depth, const DataLayout &DL, AssumptionCache *AC, - const Instruction *CxtI, const DominatorTree *DT, bool UseInstrInfo) { +KnownBits llvm::analyzeKnownBitsFromAndXorOr(const Operator *I, + const KnownBits &KnownLHS, + const KnownBits &KnownRHS, + unsigned Depth, + const SimplifyQuery &SQ) { auto *FVTy = dyn_cast(I->getType()); APInt DemandedElts = FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); - return getKnownBitsFromAndXorOr( - I, DemandedElts, KnownLHS, KnownRHS, Depth, - SimplifyQuery(DL, DT, AC, safeCxtI(I, CxtI), UseInstrInfo)); + return getKnownBitsFromAndXorOr(I, DemandedElts, KnownLHS, KnownRHS, Depth, + SQ); } ConstantRange llvm::getVScaleRange(const Function *F, unsigned BitWidth) { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 5e7ed7e165ece..a4b17372e44b3 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -207,7 +207,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?"); Known = analyzeKnownBitsFromAndXorOr(cast(I), LHSKnown, RHSKnown, - Depth, DL, &AC, CxtI, &DT); + Depth, SQ.getWithInstruction(CxtI)); // If the client is only demanding bits that we know, return the known // constant. @@ -240,7 +240,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?"); Known = analyzeKnownBitsFromAndXorOr(cast(I), LHSKnown, RHSKnown, - Depth, DL, &AC, CxtI, &DT); + Depth, SQ.getWithInstruction(CxtI)); // If the client is only demanding bits that we know, return the known // constant. @@ -279,7 +279,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?"); Known = analyzeKnownBitsFromAndXorOr(cast(I), LHSKnown, RHSKnown, - Depth, DL, &AC, CxtI, &DT); + Depth, SQ.getWithInstruction(CxtI)); // If the client is only demanding bits that we know, return the known // constant.