Skip to content

Commit

Permalink
[InstCombine] Rename TTI member for clarity (NFC)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Sep 19, 2024
1 parent 2561004 commit f1ff3a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
/// Only used to call target specific intrinsic combining.
/// It must **NOT** be used for any other purpose, as InstCombine is a
/// target-independent canonicalization transform.
TargetTransformInfo &TTI;
TargetTransformInfo &TTIForTargetIntrinsicsOnly;

public:
/// Maximum size of array considered when transforming.
Expand Down Expand Up @@ -105,7 +105,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
ProfileSummaryInfo *PSI, const DataLayout &DL,
ReversePostOrderTraversal<BasicBlock *> &RPOT)
: TTI(TTI), Builder(Builder), Worklist(Worklist),
: TTIForTargetIntrinsicsOnly(TTI), Builder(Builder), Worklist(Worklist),
MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), DT(DT), DL(DL),
SQ(DL, &TLI, &DT, &AC, nullptr, /*UseInstrInfo*/ true,
/*CanUseUndef*/ true, &DC),
Expand Down
13 changes: 8 additions & 5 deletions llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ std::optional<Instruction *>
InstCombiner::targetInstCombineIntrinsic(IntrinsicInst &II) {
// Handle target specific intrinsics
if (II.getCalledFunction()->isTargetIntrinsic()) {
return TTI.instCombineIntrinsic(*this, II);
return TTIForTargetIntrinsicsOnly.instCombineIntrinsic(*this, II);
}
return std::nullopt;
}
Expand All @@ -165,8 +165,8 @@ std::optional<Value *> InstCombiner::targetSimplifyDemandedUseBitsIntrinsic(
bool &KnownBitsComputed) {
// Handle target specific intrinsics
if (II.getCalledFunction()->isTargetIntrinsic()) {
return TTI.simplifyDemandedUseBitsIntrinsic(*this, II, DemandedMask, Known,
KnownBitsComputed);
return TTIForTargetIntrinsicsOnly.simplifyDemandedUseBitsIntrinsic(
*this, II, DemandedMask, Known, KnownBitsComputed);
}
return std::nullopt;
}
Expand All @@ -178,15 +178,18 @@ std::optional<Value *> InstCombiner::targetSimplifyDemandedVectorEltsIntrinsic(
SimplifyAndSetOp) {
// Handle target specific intrinsics
if (II.getCalledFunction()->isTargetIntrinsic()) {
return TTI.simplifyDemandedVectorEltsIntrinsic(
return TTIForTargetIntrinsicsOnly.simplifyDemandedVectorEltsIntrinsic(
*this, II, DemandedElts, PoisonElts, PoisonElts2, PoisonElts3,
SimplifyAndSetOp);
}
return std::nullopt;
}

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

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

0 comments on commit f1ff3a2

Please sign in to comment.