Skip to content

Commit

Permalink
[ValueTracking] Switch analyzeKnownBitsFromAndXorOr() to use Simplify…
Browse files Browse the repository at this point in the history
…Query (NFC)

It already used it internally, make the public API use it as well.
  • Loading branch information
nikic committed Nov 30, 2023
1 parent 5ba5211 commit 1566380
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
9 changes: 4 additions & 5 deletions llvm/include/llvm/Analysis/ValueTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const Value *> &LHSCache,
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FixedVectorType>(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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?");

Known = analyzeKnownBitsFromAndXorOr(cast<Operator>(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.
Expand Down Expand Up @@ -240,7 +240,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?");

Known = analyzeKnownBitsFromAndXorOr(cast<Operator>(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.
Expand Down Expand Up @@ -279,7 +279,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?");

Known = analyzeKnownBitsFromAndXorOr(cast<Operator>(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.
Expand Down

0 comments on commit 1566380

Please sign in to comment.