Skip to content

Commit f1ff3a2

Browse files
committed
[InstCombine] Rename TTI member for clarity (NFC)
There is already a comment on the member and documentation in the InstCombine contributor guide, but also rename it to make add an additional speed bump.
1 parent 2561004 commit f1ff3a2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

llvm/include/llvm/Transforms/InstCombine/InstCombiner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
4949
/// Only used to call target specific intrinsic combining.
5050
/// It must **NOT** be used for any other purpose, as InstCombine is a
5151
/// target-independent canonicalization transform.
52-
TargetTransformInfo &TTI;
52+
TargetTransformInfo &TTIForTargetIntrinsicsOnly;
5353

5454
public:
5555
/// Maximum size of array considered when transforming.
@@ -105,7 +105,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
105105
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
106106
ProfileSummaryInfo *PSI, const DataLayout &DL,
107107
ReversePostOrderTraversal<BasicBlock *> &RPOT)
108-
: TTI(TTI), Builder(Builder), Worklist(Worklist),
108+
: TTIForTargetIntrinsicsOnly(TTI), Builder(Builder), Worklist(Worklist),
109109
MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), DT(DT), DL(DL),
110110
SQ(DL, &TLI, &DT, &AC, nullptr, /*UseInstrInfo*/ true,
111111
/*CanUseUndef*/ true, &DC),

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ std::optional<Instruction *>
155155
InstCombiner::targetInstCombineIntrinsic(IntrinsicInst &II) {
156156
// Handle target specific intrinsics
157157
if (II.getCalledFunction()->isTargetIntrinsic()) {
158-
return TTI.instCombineIntrinsic(*this, II);
158+
return TTIForTargetIntrinsicsOnly.instCombineIntrinsic(*this, II);
159159
}
160160
return std::nullopt;
161161
}
@@ -165,8 +165,8 @@ std::optional<Value *> InstCombiner::targetSimplifyDemandedUseBitsIntrinsic(
165165
bool &KnownBitsComputed) {
166166
// Handle target specific intrinsics
167167
if (II.getCalledFunction()->isTargetIntrinsic()) {
168-
return TTI.simplifyDemandedUseBitsIntrinsic(*this, II, DemandedMask, Known,
169-
KnownBitsComputed);
168+
return TTIForTargetIntrinsicsOnly.simplifyDemandedUseBitsIntrinsic(
169+
*this, II, DemandedMask, Known, KnownBitsComputed);
170170
}
171171
return std::nullopt;
172172
}
@@ -178,15 +178,18 @@ std::optional<Value *> InstCombiner::targetSimplifyDemandedVectorEltsIntrinsic(
178178
SimplifyAndSetOp) {
179179
// Handle target specific intrinsics
180180
if (II.getCalledFunction()->isTargetIntrinsic()) {
181-
return TTI.simplifyDemandedVectorEltsIntrinsic(
181+
return TTIForTargetIntrinsicsOnly.simplifyDemandedVectorEltsIntrinsic(
182182
*this, II, DemandedElts, PoisonElts, PoisonElts2, PoisonElts3,
183183
SimplifyAndSetOp);
184184
}
185185
return std::nullopt;
186186
}
187187

188188
bool InstCombiner::isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const {
189-
return TTI.isValidAddrSpaceCast(FromAS, ToAS);
189+
// Approved exception for TTI use: This queries a legality property of the
190+
// target, not an profitability heuristic. Ideally this should be part of
191+
// DataLayout instead.
192+
return TTIForTargetIntrinsicsOnly.isValidAddrSpaceCast(FromAS, ToAS);
190193
}
191194

192195
Value *InstCombinerImpl::EmitGEPOffset(GEPOperator *GEP, bool RewriteGEP) {

0 commit comments

Comments
 (0)