Skip to content

Commit ba149f6

Browse files
committed
[ValueTracking] Add SimplifyQuery ctor without TLI (NFC)
While we pretty much always want to pass DT, AC and CxtI, most places don't care about TLI. Add an overload where this is not one of the first parameters.
1 parent 57147bb commit ba149f6

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

llvm/include/llvm/Analysis/InstructionSimplify.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ struct SimplifyQuery {
118118
bool CanUseUndef = true)
119119
: DL(DL), TLI(TLI), DT(DT), AC(AC), CxtI(CXTI), IIQ(UseInstrInfo),
120120
CanUseUndef(CanUseUndef) {}
121+
122+
SimplifyQuery(const DataLayout &DL, const DominatorTree *DT,
123+
AssumptionCache *AC = nullptr,
124+
const Instruction *CXTI = nullptr, bool UseInstrInfo = true,
125+
bool CanUseUndef = true)
126+
: DL(DL), DT(DT), AC(AC), CxtI(CXTI), IIQ(UseInstrInfo),
127+
CanUseUndef(CanUseUndef) {}
128+
121129
SimplifyQuery getWithInstruction(Instruction *I) const {
122130
SimplifyQuery Copy(*this);
123131
Copy.CxtI = I;

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,19 @@ void llvm::computeKnownBits(const Value *V, KnownBits &Known,
163163
const DataLayout &DL, unsigned Depth,
164164
AssumptionCache *AC, const Instruction *CxtI,
165165
const DominatorTree *DT, bool UseInstrInfo) {
166-
::computeKnownBits(V, Known, Depth,
167-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
168-
safeCxtI(V, CxtI), UseInstrInfo));
166+
::computeKnownBits(
167+
V, Known, Depth,
168+
SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo));
169169
}
170170

171171
void llvm::computeKnownBits(const Value *V, const APInt &DemandedElts,
172172
KnownBits &Known, const DataLayout &DL,
173173
unsigned Depth, AssumptionCache *AC,
174174
const Instruction *CxtI, const DominatorTree *DT,
175175
bool UseInstrInfo) {
176-
::computeKnownBits(V, DemandedElts, Known, Depth,
177-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
178-
safeCxtI(V, CxtI), UseInstrInfo));
176+
::computeKnownBits(
177+
V, DemandedElts, Known, Depth,
178+
SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo));
179179
}
180180

181181
static KnownBits computeKnownBits(const Value *V, const APInt &DemandedElts,
@@ -188,18 +188,17 @@ KnownBits llvm::computeKnownBits(const Value *V, const DataLayout &DL,
188188
unsigned Depth, AssumptionCache *AC,
189189
const Instruction *CxtI,
190190
const DominatorTree *DT, bool UseInstrInfo) {
191-
return ::computeKnownBits(V, Depth,
192-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
193-
safeCxtI(V, CxtI), UseInstrInfo));
191+
return ::computeKnownBits(
192+
V, Depth, SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo));
194193
}
195194

196195
KnownBits llvm::computeKnownBits(const Value *V, const APInt &DemandedElts,
197196
const DataLayout &DL, unsigned Depth,
198197
AssumptionCache *AC, const Instruction *CxtI,
199198
const DominatorTree *DT, bool UseInstrInfo) {
200-
return ::computeKnownBits(V, DemandedElts, Depth,
201-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
202-
safeCxtI(V, CxtI), UseInstrInfo));
199+
return ::computeKnownBits(
200+
V, DemandedElts, Depth,
201+
SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo));
203202
}
204203

205204
bool llvm::haveNoCommonBitsSet(const Value *LHS, const Value *RHS,
@@ -275,10 +274,9 @@ bool llvm::isKnownToBeAPowerOfTwo(const Value *V, const DataLayout &DL,
275274
bool OrZero, unsigned Depth,
276275
AssumptionCache *AC, const Instruction *CxtI,
277276
const DominatorTree *DT, bool UseInstrInfo) {
278-
return ::isKnownToBeAPowerOfTwo(V, OrZero, Depth,
279-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
280-
safeCxtI(V, CxtI),
281-
UseInstrInfo));
277+
return ::isKnownToBeAPowerOfTwo(
278+
V, OrZero, Depth,
279+
SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo));
282280
}
283281

284282
static bool isKnownNonZero(const Value *V, const APInt &DemandedElts,
@@ -290,9 +288,8 @@ static bool isKnownNonZero(const Value *V, unsigned Depth,
290288
bool llvm::isKnownNonZero(const Value *V, const DataLayout &DL, unsigned Depth,
291289
AssumptionCache *AC, const Instruction *CxtI,
292290
const DominatorTree *DT, bool UseInstrInfo) {
293-
return ::isKnownNonZero(V, Depth,
294-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
295-
safeCxtI(V, CxtI), UseInstrInfo));
291+
return ::isKnownNonZero(
292+
V, Depth, SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo));
296293
}
297294

298295
bool llvm::isKnownNonNegative(const Value *V, const DataLayout &DL,
@@ -329,9 +326,9 @@ bool llvm::isKnownNonEqual(const Value *V1, const Value *V2,
329326
const DataLayout &DL, AssumptionCache *AC,
330327
const Instruction *CxtI, const DominatorTree *DT,
331328
bool UseInstrInfo) {
332-
return ::isKnownNonEqual(V1, V2, 0,
333-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
334-
safeCxtI(V2, V1, CxtI), UseInstrInfo));
329+
return ::isKnownNonEqual(
330+
V1, V2, 0,
331+
SimplifyQuery(DL, DT, AC, safeCxtI(V2, V1, CxtI), UseInstrInfo));
335332
}
336333

337334
static bool MaskedValueIsZero(const Value *V, const APInt &Mask, unsigned Depth,
@@ -341,9 +338,9 @@ bool llvm::MaskedValueIsZero(const Value *V, const APInt &Mask,
341338
const DataLayout &DL, unsigned Depth,
342339
AssumptionCache *AC, const Instruction *CxtI,
343340
const DominatorTree *DT, bool UseInstrInfo) {
344-
return ::MaskedValueIsZero(V, Mask, Depth,
345-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
346-
safeCxtI(V, CxtI), UseInstrInfo));
341+
return ::MaskedValueIsZero(
342+
V, Mask, Depth,
343+
SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo));
347344
}
348345

349346
static unsigned ComputeNumSignBits(const Value *V, const APInt &DemandedElts,
@@ -361,9 +358,8 @@ unsigned llvm::ComputeNumSignBits(const Value *V, const DataLayout &DL,
361358
unsigned Depth, AssumptionCache *AC,
362359
const Instruction *CxtI,
363360
const DominatorTree *DT, bool UseInstrInfo) {
364-
return ::ComputeNumSignBits(V, Depth,
365-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
366-
safeCxtI(V, CxtI), UseInstrInfo));
361+
return ::ComputeNumSignBits(
362+
V, Depth, SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo));
367363
}
368364

369365
unsigned llvm::ComputeMaxSignificantBits(const Value *V, const DataLayout &DL,
@@ -956,10 +952,9 @@ KnownBits llvm::analyzeKnownBitsFromAndXorOr(
956952
APInt DemandedElts =
957953
FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1);
958954

959-
return getKnownBitsFromAndXorOr(I, DemandedElts, KnownLHS, KnownRHS, Depth,
960-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
961-
safeCxtI(I, CxtI),
962-
UseInstrInfo));
955+
return getKnownBitsFromAndXorOr(
956+
I, DemandedElts, KnownLHS, KnownRHS, Depth,
957+
SimplifyQuery(DL, DT, AC, safeCxtI(I, CxtI), UseInstrInfo));
963958
}
964959

965960
ConstantRange llvm::getVScaleRange(const Function *F, unsigned BitWidth) {
@@ -6383,9 +6378,8 @@ static OverflowResult computeOverflowForSignedAdd(const Value *LHS,
63836378
(LHSRange.isAllNegative() || RHSRange.isAllNegative());
63846379
if (LHSOrRHSKnownNonNegative || LHSOrRHSKnownNegative) {
63856380
KnownBits AddKnown(LHSRange.getBitWidth());
6386-
computeKnownBitsFromAssume(
6387-
Add, AddKnown, /*Depth=*/0,
6388-
SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC, CxtI, DT));
6381+
computeKnownBitsFromAssume(Add, AddKnown, /*Depth=*/0,
6382+
SimplifyQuery(DL, DT, AC, CxtI, DT));
63896383
if ((AddKnown.isNonNegative() && LHSOrRHSKnownNonNegative) ||
63906384
(AddKnown.isNegative() && LHSOrRHSKnownNegative))
63916385
return OverflowResult::NeverOverflows;

0 commit comments

Comments
 (0)