blob: 2f9f1e069f8f38c4f91982dec8e4f23a7ee238bc [file] [log] [blame]
Chandler Carruthd3e73552013-01-07 03:08:10 +00001//===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===//
Nadav Rotem5dc203e2012-10-18 23:22:48 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Nadav Rotem5dc203e2012-10-18 23:22:48 +00006//
7//===----------------------------------------------------------------------===//
8
Chandler Carruthd3e73552013-01-07 03:08:10 +00009#include "llvm/Analysis/TargetTransformInfo.h"
Chandler Carruth705b1852015-01-31 03:43:40 +000010#include "llvm/Analysis/TargetTransformInfoImpl.h"
Chandler Carruth219b89b2014-03-04 11:01:28 +000011#include "llvm/IR/CallSite.h"
Chandler Carruth511aa762013-01-21 01:27:39 +000012#include "llvm/IR/DataLayout.h"
Chandler Carruth511aa762013-01-21 01:27:39 +000013#include "llvm/IR/Instruction.h"
Chandler Carruth511aa762013-01-21 01:27:39 +000014#include "llvm/IR/Instructions.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000015#include "llvm/IR/IntrinsicInst.h"
Chandler Carruthe0385522015-02-01 10:11:22 +000016#include "llvm/IR/Module.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000017#include "llvm/IR/Operator.h"
Guozhi Wei62d64142017-09-08 22:29:17 +000018#include "llvm/IR/PatternMatch.h"
Sean Fertile9cd1cdf2017-07-07 02:00:06 +000019#include "llvm/Support/CommandLine.h"
Nadav Rotem5dc203e2012-10-18 23:22:48 +000020#include "llvm/Support/ErrorHandling.h"
Benjamin Kramer82de7d32016-05-27 14:27:24 +000021#include <utility>
Nadav Rotem5dc203e2012-10-18 23:22:48 +000022
23using namespace llvm;
Guozhi Wei62d64142017-09-08 22:29:17 +000024using namespace PatternMatch;
Nadav Rotem5dc203e2012-10-18 23:22:48 +000025
Chandler Carruthf1221bd2014-04-22 02:48:03 +000026#define DEBUG_TYPE "tti"
27
Guozhi Wei62d64142017-09-08 22:29:17 +000028static cl::opt<bool> EnableReduxCost("costmodel-reduxcost", cl::init(false),
29 cl::Hidden,
30 cl::desc("Recognize reduction patterns."));
31
Chandler Carruth93dcdc42015-01-31 11:17:59 +000032namespace {
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000033/// No-op implementation of the TTI interface using the utility base
Chandler Carruth93dcdc42015-01-31 11:17:59 +000034/// classes.
35///
36/// This is used when no target specific information is available.
37struct NoTTIImpl : TargetTransformInfoImplCRTPBase<NoTTIImpl> {
Mehdi Amini5010ebf2015-07-09 02:08:42 +000038 explicit NoTTIImpl(const DataLayout &DL)
Chandler Carruth93dcdc42015-01-31 11:17:59 +000039 : TargetTransformInfoImplCRTPBase<NoTTIImpl>(DL) {}
40};
41}
42
Mehdi Amini5010ebf2015-07-09 02:08:42 +000043TargetTransformInfo::TargetTransformInfo(const DataLayout &DL)
Chandler Carruth93dcdc42015-01-31 11:17:59 +000044 : TTIImpl(new Model<NoTTIImpl>(NoTTIImpl(DL))) {}
45
Chandler Carruth705b1852015-01-31 03:43:40 +000046TargetTransformInfo::~TargetTransformInfo() {}
Nadav Rotem5dc203e2012-10-18 23:22:48 +000047
Chandler Carruth705b1852015-01-31 03:43:40 +000048TargetTransformInfo::TargetTransformInfo(TargetTransformInfo &&Arg)
49 : TTIImpl(std::move(Arg.TTIImpl)) {}
Chandler Carruth539edf42013-01-05 11:43:11 +000050
Chandler Carruth705b1852015-01-31 03:43:40 +000051TargetTransformInfo &TargetTransformInfo::operator=(TargetTransformInfo &&RHS) {
52 TTIImpl = std::move(RHS.TTIImpl);
53 return *this;
Chandler Carruth539edf42013-01-05 11:43:11 +000054}
55
Chandler Carruth93205eb2015-08-05 18:08:10 +000056int TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty,
57 Type *OpTy) const {
58 int Cost = TTIImpl->getOperationCost(Opcode, Ty, OpTy);
59 assert(Cost >= 0 && "TTI should not produce negative costs!");
60 return Cost;
Chandler Carruth511aa762013-01-21 01:27:39 +000061}
62
Sjoerd Meijer31ff6472019-03-12 09:48:02 +000063int TargetTransformInfo::getCallCost(FunctionType *FTy, int NumArgs,
64 const User *U) const {
65 int Cost = TTIImpl->getCallCost(FTy, NumArgs, U);
Chandler Carruth93205eb2015-08-05 18:08:10 +000066 assert(Cost >= 0 && "TTI should not produce negative costs!");
67 return Cost;
Chandler Carruth0ba8db42013-01-22 11:26:02 +000068}
69
Chandler Carruth93205eb2015-08-05 18:08:10 +000070int TargetTransformInfo::getCallCost(const Function *F,
Sjoerd Meijer31ff6472019-03-12 09:48:02 +000071 ArrayRef<const Value *> Arguments,
72 const User *U) const {
73 int Cost = TTIImpl->getCallCost(F, Arguments, U);
Chandler Carruth93205eb2015-08-05 18:08:10 +000074 assert(Cost >= 0 && "TTI should not produce negative costs!");
75 return Cost;
Chandler Carruth0ba8db42013-01-22 11:26:02 +000076}
77
Justin Lebar8650a4d2016-04-15 01:38:48 +000078unsigned TargetTransformInfo::getInliningThresholdMultiplier() const {
79 return TTIImpl->getInliningThresholdMultiplier();
80}
81
Jingyue Wu15f3e822016-07-08 21:48:05 +000082int TargetTransformInfo::getGEPCost(Type *PointeeType, const Value *Ptr,
83 ArrayRef<const Value *> Operands) const {
84 return TTIImpl->getGEPCost(PointeeType, Ptr, Operands);
85}
86
Haicheng Wuabdef9e2017-07-15 02:12:16 +000087int TargetTransformInfo::getExtCost(const Instruction *I,
88 const Value *Src) const {
89 return TTIImpl->getExtCost(I, Src);
90}
91
Chandler Carruth93205eb2015-08-05 18:08:10 +000092int TargetTransformInfo::getIntrinsicCost(
Sjoerd Meijer31ff6472019-03-12 09:48:02 +000093 Intrinsic::ID IID, Type *RetTy, ArrayRef<const Value *> Arguments,
94 const User *U) const {
95 int Cost = TTIImpl->getIntrinsicCost(IID, RetTy, Arguments, U);
Chandler Carruth93205eb2015-08-05 18:08:10 +000096 assert(Cost >= 0 && "TTI should not produce negative costs!");
97 return Cost;
Chandler Carruth0ba8db42013-01-22 11:26:02 +000098}
99
Jun Bum Lim919f9e82017-04-28 16:04:03 +0000100unsigned
101TargetTransformInfo::getEstimatedNumberOfCaseClusters(const SwitchInst &SI,
102 unsigned &JTSize) const {
103 return TTIImpl->getEstimatedNumberOfCaseClusters(SI, JTSize);
104}
105
Evgeny Astigeevich70ed78e2017-06-29 13:42:12 +0000106int TargetTransformInfo::getUserCost(const User *U,
107 ArrayRef<const Value *> Operands) const {
108 int Cost = TTIImpl->getUserCost(U, Operands);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000109 assert(Cost >= 0 && "TTI should not produce negative costs!");
110 return Cost;
Chandler Carruth511aa762013-01-21 01:27:39 +0000111}
112
Tom Stellard8b1e0212013-07-27 00:01:07 +0000113bool TargetTransformInfo::hasBranchDivergence() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000114 return TTIImpl->hasBranchDivergence();
Tom Stellard8b1e0212013-07-27 00:01:07 +0000115}
116
Jingyue Wu5da831c2015-04-10 05:03:50 +0000117bool TargetTransformInfo::isSourceOfDivergence(const Value *V) const {
118 return TTIImpl->isSourceOfDivergence(V);
119}
120
Alexander Timofeev0f9c84c2017-06-15 19:33:10 +0000121bool llvm::TargetTransformInfo::isAlwaysUniform(const Value *V) const {
122 return TTIImpl->isAlwaysUniform(V);
123}
124
Matt Arsenault42b64782017-01-30 23:02:12 +0000125unsigned TargetTransformInfo::getFlatAddressSpace() const {
126 return TTIImpl->getFlatAddressSpace();
127}
128
Chandler Carruth0ba8db42013-01-22 11:26:02 +0000129bool TargetTransformInfo::isLoweredToCall(const Function *F) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000130 return TTIImpl->isLoweredToCall(F);
Chandler Carruth0ba8db42013-01-22 11:26:02 +0000131}
132
Chandler Carruth705b1852015-01-31 03:43:40 +0000133void TargetTransformInfo::getUnrollingPreferences(
Geoff Berry66d9bdb2017-06-28 15:53:17 +0000134 Loop *L, ScalarEvolution &SE, UnrollingPreferences &UP) const {
135 return TTIImpl->getUnrollingPreferences(L, SE, UP);
Hal Finkel8f2e7002013-09-11 19:25:43 +0000136}
137
Chandler Carruth539edf42013-01-05 11:43:11 +0000138bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000139 return TTIImpl->isLegalAddImmediate(Imm);
Chandler Carruth539edf42013-01-05 11:43:11 +0000140}
141
142bool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000143 return TTIImpl->isLegalICmpImmediate(Imm);
Chandler Carruth539edf42013-01-05 11:43:11 +0000144}
145
146bool TargetTransformInfo::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
147 int64_t BaseOffset,
148 bool HasBaseReg,
Matt Arsenaulte83379e2015-06-07 20:12:03 +0000149 int64_t Scale,
Jonas Paulsson024e3192017-07-21 11:59:37 +0000150 unsigned AddrSpace,
151 Instruction *I) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000152 return TTIImpl->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
Jonas Paulsson024e3192017-07-21 11:59:37 +0000153 Scale, AddrSpace, I);
Chandler Carruth539edf42013-01-05 11:43:11 +0000154}
155
Evgeny Stupachenkof2b3b462017-06-05 23:37:00 +0000156bool TargetTransformInfo::isLSRCostLess(LSRCost &C1, LSRCost &C2) const {
157 return TTIImpl->isLSRCostLess(C1, C2);
158}
159
Sanjay Pateld7c702b2018-02-05 23:43:05 +0000160bool TargetTransformInfo::canMacroFuseCmp() const {
161 return TTIImpl->canMacroFuseCmp();
162}
163
Krzysztof Parzyszek0b377e02018-03-26 13:10:09 +0000164bool TargetTransformInfo::shouldFavorPostInc() const {
165 return TTIImpl->shouldFavorPostInc();
166}
167
Sam Parker67756c02019-02-07 13:32:54 +0000168bool TargetTransformInfo::shouldFavorBackedgeIndex(const Loop *L) const {
169 return TTIImpl->shouldFavorBackedgeIndex(L);
170}
171
Elena Demikhovsky20662e32015-10-19 07:43:38 +0000172bool TargetTransformInfo::isLegalMaskedStore(Type *DataType) const {
173 return TTIImpl->isLegalMaskedStore(DataType);
Chandler Carruth705b1852015-01-31 03:43:40 +0000174}
175
Elena Demikhovsky20662e32015-10-19 07:43:38 +0000176bool TargetTransformInfo::isLegalMaskedLoad(Type *DataType) const {
177 return TTIImpl->isLegalMaskedLoad(DataType);
Chandler Carruth705b1852015-01-31 03:43:40 +0000178}
179
Elena Demikhovsky09285852015-10-25 15:37:55 +0000180bool TargetTransformInfo::isLegalMaskedGather(Type *DataType) const {
181 return TTIImpl->isLegalMaskedGather(DataType);
182}
183
184bool TargetTransformInfo::isLegalMaskedScatter(Type *DataType) const {
Mohammed Agabariacef53dc2017-07-27 10:28:16 +0000185 return TTIImpl->isLegalMaskedScatter(DataType);
Elena Demikhovsky09285852015-10-25 15:37:55 +0000186}
187
Craig Topper9f0b17a2019-03-21 17:38:52 +0000188bool TargetTransformInfo::isLegalMaskedCompressStore(Type *DataType) const {
189 return TTIImpl->isLegalMaskedCompressStore(DataType);
190}
191
192bool TargetTransformInfo::isLegalMaskedExpandLoad(Type *DataType) const {
193 return TTIImpl->isLegalMaskedExpandLoad(DataType);
194}
195
Sanjay Patel6fd43912017-09-09 13:38:18 +0000196bool TargetTransformInfo::hasDivRemOp(Type *DataType, bool IsSigned) const {
197 return TTIImpl->hasDivRemOp(DataType, IsSigned);
198}
199
Artem Belevichcb8f6322017-10-24 20:31:44 +0000200bool TargetTransformInfo::hasVolatileVariant(Instruction *I,
201 unsigned AddrSpace) const {
202 return TTIImpl->hasVolatileVariant(I, AddrSpace);
203}
204
Jonas Paulsson8624b7e2017-05-24 13:42:56 +0000205bool TargetTransformInfo::prefersVectorizedAddressing() const {
206 return TTIImpl->prefersVectorizedAddressing();
207}
208
Quentin Colombetbf490d42013-05-31 21:29:03 +0000209int TargetTransformInfo::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
210 int64_t BaseOffset,
211 bool HasBaseReg,
Matt Arsenaulte83379e2015-06-07 20:12:03 +0000212 int64_t Scale,
213 unsigned AddrSpace) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000214 int Cost = TTIImpl->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
215 Scale, AddrSpace);
216 assert(Cost >= 0 && "TTI should not produce negative costs!");
217 return Cost;
Quentin Colombetbf490d42013-05-31 21:29:03 +0000218}
219
Jonas Paulsson024e3192017-07-21 11:59:37 +0000220bool TargetTransformInfo::LSRWithInstrQueries() const {
221 return TTIImpl->LSRWithInstrQueries();
222}
223
Chandler Carruth539edf42013-01-05 11:43:11 +0000224bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000225 return TTIImpl->isTruncateFree(Ty1, Ty2);
Chandler Carruth539edf42013-01-05 11:43:11 +0000226}
227
Chad Rosier54390052015-02-23 19:15:16 +0000228bool TargetTransformInfo::isProfitableToHoist(Instruction *I) const {
229 return TTIImpl->isProfitableToHoist(I);
230}
231
David Blaikie8ad9a972018-03-28 22:28:50 +0000232bool TargetTransformInfo::useAA() const { return TTIImpl->useAA(); }
233
Chandler Carruth539edf42013-01-05 11:43:11 +0000234bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000235 return TTIImpl->isTypeLegal(Ty);
Chandler Carruth539edf42013-01-05 11:43:11 +0000236}
237
238unsigned TargetTransformInfo::getJumpBufAlignment() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000239 return TTIImpl->getJumpBufAlignment();
Chandler Carruth539edf42013-01-05 11:43:11 +0000240}
241
242unsigned TargetTransformInfo::getJumpBufSize() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000243 return TTIImpl->getJumpBufSize();
Chandler Carruth539edf42013-01-05 11:43:11 +0000244}
245
246bool TargetTransformInfo::shouldBuildLookupTables() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000247 return TTIImpl->shouldBuildLookupTables();
Chandler Carruth539edf42013-01-05 11:43:11 +0000248}
Oliver Stannard4df1cc02016-10-07 08:48:24 +0000249bool TargetTransformInfo::shouldBuildLookupTablesForConstant(Constant *C) const {
250 return TTIImpl->shouldBuildLookupTablesForConstant(C);
251}
Chandler Carruth539edf42013-01-05 11:43:11 +0000252
Zaara Syeda1f59ae32018-01-30 16:17:22 +0000253bool TargetTransformInfo::useColdCCForColdCall(Function &F) const {
254 return TTIImpl->useColdCCForColdCall(F);
255}
256
Jonas Paulsson8e2f9482017-01-26 07:03:25 +0000257unsigned TargetTransformInfo::
258getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const {
259 return TTIImpl->getScalarizationOverhead(Ty, Insert, Extract);
260}
261
262unsigned TargetTransformInfo::
263getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
264 unsigned VF) const {
265 return TTIImpl->getOperandsScalarizationOverhead(Args, VF);
266}
267
Jonas Paulssonda74ed42017-04-12 12:41:37 +0000268bool TargetTransformInfo::supportsEfficientVectorElementLoadStore() const {
269 return TTIImpl->supportsEfficientVectorElementLoadStore();
270}
271
Olivier Sallenave049d8032015-03-06 23:12:04 +0000272bool TargetTransformInfo::enableAggressiveInterleaving(bool LoopHasReductions) const {
273 return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
274}
275
Clement Courbetb2c3eb82017-10-30 14:19:33 +0000276const TargetTransformInfo::MemCmpExpansionOptions *
277TargetTransformInfo::enableMemCmpExpansion(bool IsZeroCmp) const {
278 return TTIImpl->enableMemCmpExpansion(IsZeroCmp);
Zaara Syeda3a7578c2017-05-31 17:12:38 +0000279}
280
Silviu Baranga61bdc512015-08-10 14:50:54 +0000281bool TargetTransformInfo::enableInterleavedAccessVectorization() const {
282 return TTIImpl->enableInterleavedAccessVectorization();
283}
284
Dorit Nuzman38bbf812018-10-14 08:50:06 +0000285bool TargetTransformInfo::enableMaskedInterleavedAccessVectorization() const {
286 return TTIImpl->enableMaskedInterleavedAccessVectorization();
287}
288
Renato Golin5cb666a2016-04-14 20:42:18 +0000289bool TargetTransformInfo::isFPVectorizationPotentiallyUnsafe() const {
290 return TTIImpl->isFPVectorizationPotentiallyUnsafe();
291}
292
Alina Sbirlea6f937b12016-08-04 16:38:44 +0000293bool TargetTransformInfo::allowsMisalignedMemoryAccesses(LLVMContext &Context,
294 unsigned BitWidth,
Alina Sbirlea327955e2016-07-11 20:46:17 +0000295 unsigned AddressSpace,
296 unsigned Alignment,
297 bool *Fast) const {
Alina Sbirlea6f937b12016-08-04 16:38:44 +0000298 return TTIImpl->allowsMisalignedMemoryAccesses(Context, BitWidth, AddressSpace,
Alina Sbirlea327955e2016-07-11 20:46:17 +0000299 Alignment, Fast);
300}
301
Chandler Carruth50a36cd2013-01-07 03:16:03 +0000302TargetTransformInfo::PopcntSupportKind
303TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000304 return TTIImpl->getPopcntSupport(IntTyWidthInBit);
Chandler Carruth539edf42013-01-05 11:43:11 +0000305}
306
Richard Sandiford37cd6cf2013-08-23 10:27:02 +0000307bool TargetTransformInfo::haveFastSqrt(Type *Ty) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000308 return TTIImpl->haveFastSqrt(Ty);
Richard Sandiford37cd6cf2013-08-23 10:27:02 +0000309}
310
Sanjay Patel0de1a4b2017-11-27 21:15:43 +0000311bool TargetTransformInfo::isFCmpOrdCheaperThanFCmpZero(Type *Ty) const {
312 return TTIImpl->isFCmpOrdCheaperThanFCmpZero(Ty);
313}
314
Chandler Carruth93205eb2015-08-05 18:08:10 +0000315int TargetTransformInfo::getFPOpCost(Type *Ty) const {
316 int Cost = TTIImpl->getFPOpCost(Ty);
317 assert(Cost >= 0 && "TTI should not produce negative costs!");
318 return Cost;
Cameron Esfahani17177d12015-02-05 02:09:33 +0000319}
320
Sjoerd Meijer38c2cd02016-07-14 07:44:20 +0000321int TargetTransformInfo::getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
322 const APInt &Imm,
323 Type *Ty) const {
324 int Cost = TTIImpl->getIntImmCodeSizeCost(Opcode, Idx, Imm, Ty);
325 assert(Cost >= 0 && "TTI should not produce negative costs!");
326 return Cost;
327}
328
Chandler Carruth93205eb2015-08-05 18:08:10 +0000329int TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
330 int Cost = TTIImpl->getIntImmCost(Imm, Ty);
331 assert(Cost >= 0 && "TTI should not produce negative costs!");
332 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000333}
334
Chandler Carruth93205eb2015-08-05 18:08:10 +0000335int TargetTransformInfo::getIntImmCost(unsigned Opcode, unsigned Idx,
336 const APInt &Imm, Type *Ty) const {
337 int Cost = TTIImpl->getIntImmCost(Opcode, Idx, Imm, Ty);
338 assert(Cost >= 0 && "TTI should not produce negative costs!");
339 return Cost;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +0000340}
341
Chandler Carruth93205eb2015-08-05 18:08:10 +0000342int TargetTransformInfo::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
343 const APInt &Imm, Type *Ty) const {
344 int Cost = TTIImpl->getIntImmCost(IID, Idx, Imm, Ty);
345 assert(Cost >= 0 && "TTI should not produce negative costs!");
346 return Cost;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +0000347}
348
Chandler Carruth539edf42013-01-05 11:43:11 +0000349unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000350 return TTIImpl->getNumberOfRegisters(Vector);
Chandler Carruth539edf42013-01-05 11:43:11 +0000351}
352
Nadav Rotemb1791a72013-01-09 22:29:00 +0000353unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000354 return TTIImpl->getRegisterBitWidth(Vector);
Nadav Rotemb1791a72013-01-09 22:29:00 +0000355}
356
Adam Nemete29686e2017-05-15 21:15:01 +0000357unsigned TargetTransformInfo::getMinVectorRegisterBitWidth() const {
358 return TTIImpl->getMinVectorRegisterBitWidth();
359}
360
Krzysztof Parzyszek5d93fdf2018-03-27 16:14:11 +0000361bool TargetTransformInfo::shouldMaximizeVectorBandwidth(bool OptSize) const {
362 return TTIImpl->shouldMaximizeVectorBandwidth(OptSize);
363}
364
Krzysztof Parzyszekdfed9412018-04-13 20:16:32 +0000365unsigned TargetTransformInfo::getMinimumVF(unsigned ElemWidth) const {
366 return TTIImpl->getMinimumVF(ElemWidth);
367}
368
Jun Bum Limdee55652017-04-03 19:20:07 +0000369bool TargetTransformInfo::shouldConsiderAddressTypePromotion(
370 const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const {
371 return TTIImpl->shouldConsiderAddressTypePromotion(
372 I, AllowPromotionWithoutCommonHeader);
373}
374
Adam Nemetaf761102016-01-21 18:28:36 +0000375unsigned TargetTransformInfo::getCacheLineSize() const {
376 return TTIImpl->getCacheLineSize();
377}
378
Tobias Grosserd7eb6192017-08-24 09:46:25 +0000379llvm::Optional<unsigned> TargetTransformInfo::getCacheSize(CacheLevel Level)
380 const {
381 return TTIImpl->getCacheSize(Level);
382}
383
384llvm::Optional<unsigned> TargetTransformInfo::getCacheAssociativity(
385 CacheLevel Level) const {
386 return TTIImpl->getCacheAssociativity(Level);
387}
388
Adam Nemetdadfbb52016-01-27 22:21:25 +0000389unsigned TargetTransformInfo::getPrefetchDistance() const {
390 return TTIImpl->getPrefetchDistance();
391}
392
Adam Nemet6d8beec2016-03-18 00:27:38 +0000393unsigned TargetTransformInfo::getMinPrefetchStride() const {
394 return TTIImpl->getMinPrefetchStride();
395}
396
Adam Nemet709e3042016-03-18 00:27:43 +0000397unsigned TargetTransformInfo::getMaxPrefetchIterationsAhead() const {
398 return TTIImpl->getMaxPrefetchIterationsAhead();
399}
400
Wei Mi062c7442015-05-06 17:12:25 +0000401unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
402 return TTIImpl->getMaxInterleaveFactor(VF);
Nadav Rotemb696c362013-01-09 01:15:42 +0000403}
404
Jonas Paulsson29d80f02018-10-05 14:34:04 +0000405TargetTransformInfo::OperandValueKind
Simon Pilgrim077a42c2018-11-13 13:45:10 +0000406TargetTransformInfo::getOperandInfo(Value *V, OperandValueProperties &OpProps) {
Jonas Paulsson29d80f02018-10-05 14:34:04 +0000407 OperandValueKind OpInfo = OK_AnyValue;
408 OpProps = OP_None;
409
410 if (auto *CI = dyn_cast<ConstantInt>(V)) {
411 if (CI->getValue().isPowerOf2())
412 OpProps = OP_PowerOf2;
413 return OK_UniformConstantValue;
414 }
415
Simon Pilgrim2b166c52018-11-14 15:04:08 +0000416 // A broadcast shuffle creates a uniform value.
417 // TODO: Add support for non-zero index broadcasts.
418 // TODO: Add support for different source vector width.
419 if (auto *ShuffleInst = dyn_cast<ShuffleVectorInst>(V))
420 if (ShuffleInst->isZeroEltSplat())
421 OpInfo = OK_UniformValue;
422
Jonas Paulsson29d80f02018-10-05 14:34:04 +0000423 const Value *Splat = getSplatValue(V);
424
425 // Check for a splat of a constant or for a non uniform vector of constants
426 // and check if the constant(s) are all powers of two.
427 if (isa<ConstantVector>(V) || isa<ConstantDataVector>(V)) {
428 OpInfo = OK_NonUniformConstantValue;
429 if (Splat) {
430 OpInfo = OK_UniformConstantValue;
431 if (auto *CI = dyn_cast<ConstantInt>(Splat))
432 if (CI->getValue().isPowerOf2())
433 OpProps = OP_PowerOf2;
434 } else if (auto *CDS = dyn_cast<ConstantDataSequential>(V)) {
435 OpProps = OP_PowerOf2;
436 for (unsigned I = 0, E = CDS->getNumElements(); I != E; ++I) {
437 if (auto *CI = dyn_cast<ConstantInt>(CDS->getElementAsConstant(I)))
438 if (CI->getValue().isPowerOf2())
439 continue;
440 OpProps = OP_None;
441 break;
442 }
443 }
444 }
445
446 // Check for a splat of a uniform value. This is not loop aware, so return
447 // true only for the obviously uniform cases (argument, globalvalue)
448 if (Splat && (isa<Argument>(Splat) || isa<GlobalValue>(Splat)))
449 OpInfo = OK_UniformValue;
450
451 return OpInfo;
452}
453
Chandler Carruth93205eb2015-08-05 18:08:10 +0000454int TargetTransformInfo::getArithmeticInstrCost(
Chandler Carruth705b1852015-01-31 03:43:40 +0000455 unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
456 OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
Mohammed Agabaria2c96c432017-01-11 08:23:37 +0000457 OperandValueProperties Opd2PropInfo,
458 ArrayRef<const Value *> Args) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000459 int Cost = TTIImpl->getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
Mohammed Agabaria2c96c432017-01-11 08:23:37 +0000460 Opd1PropInfo, Opd2PropInfo, Args);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000461 assert(Cost >= 0 && "TTI should not produce negative costs!");
462 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000463}
464
Chandler Carruth93205eb2015-08-05 18:08:10 +0000465int TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Ty, int Index,
466 Type *SubTp) const {
467 int Cost = TTIImpl->getShuffleCost(Kind, Ty, Index, SubTp);
468 assert(Cost >= 0 && "TTI should not produce negative costs!");
469 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000470}
471
Chandler Carruth93205eb2015-08-05 18:08:10 +0000472int TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
Jonas Paulssonfccc7d62017-04-12 11:49:08 +0000473 Type *Src, const Instruction *I) const {
474 assert ((I == nullptr || I->getOpcode() == Opcode) &&
475 "Opcode should reflect passed instruction.");
476 int Cost = TTIImpl->getCastInstrCost(Opcode, Dst, Src, I);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000477 assert(Cost >= 0 && "TTI should not produce negative costs!");
478 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000479}
480
Matthew Simpsone5dfb082016-04-27 15:20:21 +0000481int TargetTransformInfo::getExtractWithExtendCost(unsigned Opcode, Type *Dst,
482 VectorType *VecTy,
483 unsigned Index) const {
484 int Cost = TTIImpl->getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
485 assert(Cost >= 0 && "TTI should not produce negative costs!");
486 return Cost;
487}
488
Chandler Carruth93205eb2015-08-05 18:08:10 +0000489int TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
490 int Cost = TTIImpl->getCFInstrCost(Opcode);
491 assert(Cost >= 0 && "TTI should not produce negative costs!");
492 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000493}
494
Chandler Carruth93205eb2015-08-05 18:08:10 +0000495int TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
Jonas Paulssonfccc7d62017-04-12 11:49:08 +0000496 Type *CondTy, const Instruction *I) const {
497 assert ((I == nullptr || I->getOpcode() == Opcode) &&
498 "Opcode should reflect passed instruction.");
499 int Cost = TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy, I);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000500 assert(Cost >= 0 && "TTI should not produce negative costs!");
501 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000502}
503
Chandler Carruth93205eb2015-08-05 18:08:10 +0000504int TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
505 unsigned Index) const {
506 int Cost = TTIImpl->getVectorInstrCost(Opcode, Val, Index);
507 assert(Cost >= 0 && "TTI should not produce negative costs!");
508 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000509}
510
Chandler Carruth93205eb2015-08-05 18:08:10 +0000511int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
512 unsigned Alignment,
Jonas Paulssonfccc7d62017-04-12 11:49:08 +0000513 unsigned AddressSpace,
514 const Instruction *I) const {
515 assert ((I == nullptr || I->getOpcode() == Opcode) &&
516 "Opcode should reflect passed instruction.");
517 int Cost = TTIImpl->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, I);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000518 assert(Cost >= 0 && "TTI should not produce negative costs!");
519 return Cost;
Elena Demikhovskya3232f72015-01-25 08:44:46 +0000520}
521
Chandler Carruth93205eb2015-08-05 18:08:10 +0000522int TargetTransformInfo::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
523 unsigned Alignment,
524 unsigned AddressSpace) const {
525 int Cost =
526 TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
527 assert(Cost >= 0 && "TTI should not produce negative costs!");
528 return Cost;
Chandler Carruth705b1852015-01-31 03:43:40 +0000529}
530
Elena Demikhovsky54946982015-12-28 20:10:59 +0000531int TargetTransformInfo::getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
532 Value *Ptr, bool VariableMask,
533 unsigned Alignment) const {
534 int Cost = TTIImpl->getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
535 Alignment);
536 assert(Cost >= 0 && "TTI should not produce negative costs!");
537 return Cost;
538}
539
Chandler Carruth93205eb2015-08-05 18:08:10 +0000540int TargetTransformInfo::getInterleavedMemoryOpCost(
Hao Liu32c05392015-06-08 06:39:56 +0000541 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
Dorit Nuzman34da6dd2018-10-31 09:57:56 +0000542 unsigned Alignment, unsigned AddressSpace, bool UseMaskForCond,
543 bool UseMaskForGaps) const {
544 int Cost = TTIImpl->getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
545 Alignment, AddressSpace,
546 UseMaskForCond,
547 UseMaskForGaps);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000548 assert(Cost >= 0 && "TTI should not produce negative costs!");
549 return Cost;
Hao Liu32c05392015-06-08 06:39:56 +0000550}
551
Chandler Carruth93205eb2015-08-05 18:08:10 +0000552int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
Jonas Paulssona48ea232017-03-14 06:35:36 +0000553 ArrayRef<Type *> Tys, FastMathFlags FMF,
554 unsigned ScalarizationCostPassed) const {
555 int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Tys, FMF,
556 ScalarizationCostPassed);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000557 assert(Cost >= 0 && "TTI should not produce negative costs!");
558 return Cost;
559}
560
Elena Demikhovsky54946982015-12-28 20:10:59 +0000561int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
Jonas Paulssona48ea232017-03-14 06:35:36 +0000562 ArrayRef<Value *> Args, FastMathFlags FMF, unsigned VF) const {
563 int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Args, FMF, VF);
Elena Demikhovsky54946982015-12-28 20:10:59 +0000564 assert(Cost >= 0 && "TTI should not produce negative costs!");
565 return Cost;
566}
567
Chandler Carruth93205eb2015-08-05 18:08:10 +0000568int TargetTransformInfo::getCallInstrCost(Function *F, Type *RetTy,
569 ArrayRef<Type *> Tys) const {
570 int Cost = TTIImpl->getCallInstrCost(F, RetTy, Tys);
571 assert(Cost >= 0 && "TTI should not produce negative costs!");
572 return Cost;
Michael Zolotukhin7ed84a82015-03-17 19:26:23 +0000573}
574
Chandler Carruth539edf42013-01-05 11:43:11 +0000575unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000576 return TTIImpl->getNumberOfParts(Tp);
Chandler Carruth539edf42013-01-05 11:43:11 +0000577}
578
Chandler Carruth93205eb2015-08-05 18:08:10 +0000579int TargetTransformInfo::getAddressComputationCost(Type *Tp,
Mohammed Agabaria23599ba2017-01-05 14:03:41 +0000580 ScalarEvolution *SE,
581 const SCEV *Ptr) const {
582 int Cost = TTIImpl->getAddressComputationCost(Tp, SE, Ptr);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000583 assert(Cost >= 0 && "TTI should not produce negative costs!");
584 return Cost;
Arnold Schwaighofer594fa2d2013-02-08 14:50:48 +0000585}
Chandler Carruth539edf42013-01-05 11:43:11 +0000586
Sjoerd Meijerea31ddb2019-04-30 10:28:50 +0000587int TargetTransformInfo::getMemcpyCost(const Instruction *I) const {
588 int Cost = TTIImpl->getMemcpyCost(I);
589 assert(Cost >= 0 && "TTI should not produce negative costs!");
590 return Cost;
591}
592
Alexey Bataev3e9b3eb2017-07-31 14:19:32 +0000593int TargetTransformInfo::getArithmeticReductionCost(unsigned Opcode, Type *Ty,
594 bool IsPairwiseForm) const {
595 int Cost = TTIImpl->getArithmeticReductionCost(Opcode, Ty, IsPairwiseForm);
Chandler Carruth93205eb2015-08-05 18:08:10 +0000596 assert(Cost >= 0 && "TTI should not produce negative costs!");
597 return Cost;
Arnold Schwaighofercae87352013-09-17 18:06:50 +0000598}
599
Alexey Bataev6dd29fc2017-09-08 13:49:36 +0000600int TargetTransformInfo::getMinMaxReductionCost(Type *Ty, Type *CondTy,
601 bool IsPairwiseForm,
602 bool IsUnsigned) const {
603 int Cost =
604 TTIImpl->getMinMaxReductionCost(Ty, CondTy, IsPairwiseForm, IsUnsigned);
605 assert(Cost >= 0 && "TTI should not produce negative costs!");
606 return Cost;
607}
608
Chandler Carruth705b1852015-01-31 03:43:40 +0000609unsigned
610TargetTransformInfo::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const {
611 return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
Chad Rosierf9327d62015-01-26 22:51:15 +0000612}
613
614bool TargetTransformInfo::getTgtMemIntrinsic(IntrinsicInst *Inst,
615 MemIntrinsicInfo &Info) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000616 return TTIImpl->getTgtMemIntrinsic(Inst, Info);
Chad Rosierf9327d62015-01-26 22:51:15 +0000617}
618
Anna Thomasb2a212c2017-06-06 16:45:25 +0000619unsigned TargetTransformInfo::getAtomicMemIntrinsicMaxElementSize() const {
620 return TTIImpl->getAtomicMemIntrinsicMaxElementSize();
621}
622
Chandler Carruth705b1852015-01-31 03:43:40 +0000623Value *TargetTransformInfo::getOrCreateResultFromMemIntrinsic(
624 IntrinsicInst *Inst, Type *ExpectedType) const {
625 return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
626}
627
Sean Fertile9cd1cdf2017-07-07 02:00:06 +0000628Type *TargetTransformInfo::getMemcpyLoopLoweringType(LLVMContext &Context,
629 Value *Length,
630 unsigned SrcAlign,
631 unsigned DestAlign) const {
632 return TTIImpl->getMemcpyLoopLoweringType(Context, Length, SrcAlign,
633 DestAlign);
634}
635
636void TargetTransformInfo::getMemcpyLoopResidualLoweringType(
637 SmallVectorImpl<Type *> &OpsOut, LLVMContext &Context,
638 unsigned RemainingBytes, unsigned SrcAlign, unsigned DestAlign) const {
639 TTIImpl->getMemcpyLoopResidualLoweringType(OpsOut, Context, RemainingBytes,
640 SrcAlign, DestAlign);
641}
642
Eric Christopherd566fb12015-07-29 22:09:48 +0000643bool TargetTransformInfo::areInlineCompatible(const Function *Caller,
644 const Function *Callee) const {
645 return TTIImpl->areInlineCompatible(Caller, Callee);
Eric Christopher4371b132015-07-02 01:11:47 +0000646}
647
Tom Stellard3d36e5c2019-01-16 05:15:31 +0000648bool TargetTransformInfo::areFunctionArgsABICompatible(
649 const Function *Caller, const Function *Callee,
650 SmallPtrSetImpl<Argument *> &Args) const {
651 return TTIImpl->areFunctionArgsABICompatible(Caller, Callee, Args);
652}
653
Krzysztof Parzyszek0b377e02018-03-26 13:10:09 +0000654bool TargetTransformInfo::isIndexedLoadLegal(MemIndexedMode Mode,
655 Type *Ty) const {
656 return TTIImpl->isIndexedLoadLegal(Mode, Ty);
657}
658
659bool TargetTransformInfo::isIndexedStoreLegal(MemIndexedMode Mode,
660 Type *Ty) const {
661 return TTIImpl->isIndexedStoreLegal(Mode, Ty);
662}
663
Volkan Keles1c386812016-10-03 10:31:34 +0000664unsigned TargetTransformInfo::getLoadStoreVecRegBitWidth(unsigned AS) const {
665 return TTIImpl->getLoadStoreVecRegBitWidth(AS);
666}
667
668bool TargetTransformInfo::isLegalToVectorizeLoad(LoadInst *LI) const {
669 return TTIImpl->isLegalToVectorizeLoad(LI);
670}
671
672bool TargetTransformInfo::isLegalToVectorizeStore(StoreInst *SI) const {
673 return TTIImpl->isLegalToVectorizeStore(SI);
674}
675
676bool TargetTransformInfo::isLegalToVectorizeLoadChain(
677 unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
678 return TTIImpl->isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
679 AddrSpace);
680}
681
682bool TargetTransformInfo::isLegalToVectorizeStoreChain(
683 unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
684 return TTIImpl->isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
685 AddrSpace);
686}
687
688unsigned TargetTransformInfo::getLoadVectorFactor(unsigned VF,
689 unsigned LoadSize,
690 unsigned ChainSizeInBytes,
691 VectorType *VecTy) const {
692 return TTIImpl->getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
693}
694
695unsigned TargetTransformInfo::getStoreVectorFactor(unsigned VF,
696 unsigned StoreSize,
697 unsigned ChainSizeInBytes,
698 VectorType *VecTy) const {
699 return TTIImpl->getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
700}
701
Amara Emersoncf9daa32017-05-09 10:43:25 +0000702bool TargetTransformInfo::useReductionIntrinsic(unsigned Opcode,
703 Type *Ty, ReductionFlags Flags) const {
704 return TTIImpl->useReductionIntrinsic(Opcode, Ty, Flags);
705}
706
Amara Emerson836b0f42017-05-10 09:42:49 +0000707bool TargetTransformInfo::shouldExpandReduction(const IntrinsicInst *II) const {
708 return TTIImpl->shouldExpandReduction(II);
709}
Amara Emersoncf9daa32017-05-09 10:43:25 +0000710
Guozhi Wei62d64142017-09-08 22:29:17 +0000711int TargetTransformInfo::getInstructionLatency(const Instruction *I) const {
712 return TTIImpl->getInstructionLatency(I);
713}
714
Guozhi Wei62d64142017-09-08 22:29:17 +0000715static bool matchPairwiseShuffleMask(ShuffleVectorInst *SI, bool IsLeft,
716 unsigned Level) {
717 // We don't need a shuffle if we just want to have element 0 in position 0 of
718 // the vector.
719 if (!SI && Level == 0 && IsLeft)
720 return true;
721 else if (!SI)
722 return false;
723
724 SmallVector<int, 32> Mask(SI->getType()->getVectorNumElements(), -1);
725
726 // Build a mask of 0, 2, ... (left) or 1, 3, ... (right) depending on whether
727 // we look at the left or right side.
728 for (unsigned i = 0, e = (1 << Level), val = !IsLeft; i != e; ++i, val += 2)
729 Mask[i] = val;
730
731 SmallVector<int, 16> ActualMask = SI->getShuffleMask();
732 return Mask == ActualMask;
733}
734
735namespace {
736/// Kind of the reduction data.
737enum ReductionKind {
738 RK_None, /// Not a reduction.
739 RK_Arithmetic, /// Binary reduction data.
740 RK_MinMax, /// Min/max reduction data.
741 RK_UnsignedMinMax, /// Unsigned min/max reduction data.
742};
743/// Contains opcode + LHS/RHS parts of the reduction operations.
744struct ReductionData {
745 ReductionData() = delete;
746 ReductionData(ReductionKind Kind, unsigned Opcode, Value *LHS, Value *RHS)
747 : Opcode(Opcode), LHS(LHS), RHS(RHS), Kind(Kind) {
748 assert(Kind != RK_None && "expected binary or min/max reduction only.");
749 }
750 unsigned Opcode = 0;
751 Value *LHS = nullptr;
752 Value *RHS = nullptr;
753 ReductionKind Kind = RK_None;
754 bool hasSameData(ReductionData &RD) const {
755 return Kind == RD.Kind && Opcode == RD.Opcode;
756 }
757};
758} // namespace
759
760static Optional<ReductionData> getReductionData(Instruction *I) {
761 Value *L, *R;
762 if (m_BinOp(m_Value(L), m_Value(R)).match(I))
Fangrui Songf78650a2018-07-30 19:41:25 +0000763 return ReductionData(RK_Arithmetic, I->getOpcode(), L, R);
Guozhi Wei62d64142017-09-08 22:29:17 +0000764 if (auto *SI = dyn_cast<SelectInst>(I)) {
765 if (m_SMin(m_Value(L), m_Value(R)).match(SI) ||
766 m_SMax(m_Value(L), m_Value(R)).match(SI) ||
767 m_OrdFMin(m_Value(L), m_Value(R)).match(SI) ||
768 m_OrdFMax(m_Value(L), m_Value(R)).match(SI) ||
769 m_UnordFMin(m_Value(L), m_Value(R)).match(SI) ||
770 m_UnordFMax(m_Value(L), m_Value(R)).match(SI)) {
771 auto *CI = cast<CmpInst>(SI->getCondition());
Fangrui Songf78650a2018-07-30 19:41:25 +0000772 return ReductionData(RK_MinMax, CI->getOpcode(), L, R);
773 }
Guozhi Wei62d64142017-09-08 22:29:17 +0000774 if (m_UMin(m_Value(L), m_Value(R)).match(SI) ||
775 m_UMax(m_Value(L), m_Value(R)).match(SI)) {
776 auto *CI = cast<CmpInst>(SI->getCondition());
777 return ReductionData(RK_UnsignedMinMax, CI->getOpcode(), L, R);
778 }
779 }
780 return llvm::None;
781}
782
783static ReductionKind matchPairwiseReductionAtLevel(Instruction *I,
784 unsigned Level,
785 unsigned NumLevels) {
786 // Match one level of pairwise operations.
787 // %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef,
788 // <4 x i32> <i32 0, i32 2 , i32 undef, i32 undef>
789 // %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef,
790 // <4 x i32> <i32 1, i32 3, i32 undef, i32 undef>
791 // %bin.rdx.0 = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1
792 if (!I)
793 return RK_None;
794
795 assert(I->getType()->isVectorTy() && "Expecting a vector type");
796
797 Optional<ReductionData> RD = getReductionData(I);
798 if (!RD)
799 return RK_None;
800
801 ShuffleVectorInst *LS = dyn_cast<ShuffleVectorInst>(RD->LHS);
802 if (!LS && Level)
803 return RK_None;
804 ShuffleVectorInst *RS = dyn_cast<ShuffleVectorInst>(RD->RHS);
805 if (!RS && Level)
806 return RK_None;
807
808 // On level 0 we can omit one shufflevector instruction.
809 if (!Level && !RS && !LS)
810 return RK_None;
811
812 // Shuffle inputs must match.
813 Value *NextLevelOpL = LS ? LS->getOperand(0) : nullptr;
814 Value *NextLevelOpR = RS ? RS->getOperand(0) : nullptr;
815 Value *NextLevelOp = nullptr;
816 if (NextLevelOpR && NextLevelOpL) {
817 // If we have two shuffles their operands must match.
818 if (NextLevelOpL != NextLevelOpR)
819 return RK_None;
820
821 NextLevelOp = NextLevelOpL;
822 } else if (Level == 0 && (NextLevelOpR || NextLevelOpL)) {
823 // On the first level we can omit the shufflevector <0, undef,...>. So the
824 // input to the other shufflevector <1, undef> must match with one of the
825 // inputs to the current binary operation.
826 // Example:
827 // %NextLevelOpL = shufflevector %R, <1, undef ...>
828 // %BinOp = fadd %NextLevelOpL, %R
829 if (NextLevelOpL && NextLevelOpL != RD->RHS)
830 return RK_None;
831 else if (NextLevelOpR && NextLevelOpR != RD->LHS)
832 return RK_None;
833
834 NextLevelOp = NextLevelOpL ? RD->RHS : RD->LHS;
835 } else
836 return RK_None;
837
838 // Check that the next levels binary operation exists and matches with the
839 // current one.
840 if (Level + 1 != NumLevels) {
841 Optional<ReductionData> NextLevelRD =
842 getReductionData(cast<Instruction>(NextLevelOp));
843 if (!NextLevelRD || !RD->hasSameData(*NextLevelRD))
844 return RK_None;
845 }
846
847 // Shuffle mask for pairwise operation must match.
848 if (matchPairwiseShuffleMask(LS, /*IsLeft=*/true, Level)) {
849 if (!matchPairwiseShuffleMask(RS, /*IsLeft=*/false, Level))
850 return RK_None;
851 } else if (matchPairwiseShuffleMask(RS, /*IsLeft=*/true, Level)) {
852 if (!matchPairwiseShuffleMask(LS, /*IsLeft=*/false, Level))
853 return RK_None;
854 } else {
855 return RK_None;
856 }
857
858 if (++Level == NumLevels)
859 return RD->Kind;
860
861 // Match next level.
862 return matchPairwiseReductionAtLevel(cast<Instruction>(NextLevelOp), Level,
863 NumLevels);
864}
865
866static ReductionKind matchPairwiseReduction(const ExtractElementInst *ReduxRoot,
867 unsigned &Opcode, Type *&Ty) {
868 if (!EnableReduxCost)
869 return RK_None;
870
871 // Need to extract the first element.
872 ConstantInt *CI = dyn_cast<ConstantInt>(ReduxRoot->getOperand(1));
873 unsigned Idx = ~0u;
874 if (CI)
875 Idx = CI->getZExtValue();
876 if (Idx != 0)
877 return RK_None;
878
879 auto *RdxStart = dyn_cast<Instruction>(ReduxRoot->getOperand(0));
880 if (!RdxStart)
881 return RK_None;
882 Optional<ReductionData> RD = getReductionData(RdxStart);
883 if (!RD)
884 return RK_None;
885
886 Type *VecTy = RdxStart->getType();
887 unsigned NumVecElems = VecTy->getVectorNumElements();
888 if (!isPowerOf2_32(NumVecElems))
889 return RK_None;
890
891 // We look for a sequence of shuffle,shuffle,add triples like the following
892 // that builds a pairwise reduction tree.
Fangrui Songf78650a2018-07-30 19:41:25 +0000893 //
Guozhi Wei62d64142017-09-08 22:29:17 +0000894 // (X0, X1, X2, X3)
895 // (X0 + X1, X2 + X3, undef, undef)
896 // ((X0 + X1) + (X2 + X3), undef, undef, undef)
Fangrui Songf78650a2018-07-30 19:41:25 +0000897 //
Guozhi Wei62d64142017-09-08 22:29:17 +0000898 // %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef,
899 // <4 x i32> <i32 0, i32 2 , i32 undef, i32 undef>
900 // %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef,
901 // <4 x i32> <i32 1, i32 3, i32 undef, i32 undef>
902 // %bin.rdx.0 = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1
903 // %rdx.shuf.1.0 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef,
904 // <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
905 // %rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef,
906 // <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
907 // %bin.rdx8 = fadd <4 x float> %rdx.shuf.1.0, %rdx.shuf.1.1
908 // %r = extractelement <4 x float> %bin.rdx8, i32 0
909 if (matchPairwiseReductionAtLevel(RdxStart, 0, Log2_32(NumVecElems)) ==
910 RK_None)
911 return RK_None;
912
913 Opcode = RD->Opcode;
914 Ty = VecTy;
915
916 return RD->Kind;
917}
918
919static std::pair<Value *, ShuffleVectorInst *>
920getShuffleAndOtherOprd(Value *L, Value *R) {
921 ShuffleVectorInst *S = nullptr;
922
923 if ((S = dyn_cast<ShuffleVectorInst>(L)))
924 return std::make_pair(R, S);
925
926 S = dyn_cast<ShuffleVectorInst>(R);
927 return std::make_pair(L, S);
928}
929
930static ReductionKind
931matchVectorSplittingReduction(const ExtractElementInst *ReduxRoot,
932 unsigned &Opcode, Type *&Ty) {
933 if (!EnableReduxCost)
934 return RK_None;
935
936 // Need to extract the first element.
937 ConstantInt *CI = dyn_cast<ConstantInt>(ReduxRoot->getOperand(1));
938 unsigned Idx = ~0u;
939 if (CI)
940 Idx = CI->getZExtValue();
941 if (Idx != 0)
942 return RK_None;
943
944 auto *RdxStart = dyn_cast<Instruction>(ReduxRoot->getOperand(0));
945 if (!RdxStart)
946 return RK_None;
947 Optional<ReductionData> RD = getReductionData(RdxStart);
948 if (!RD)
949 return RK_None;
950
951 Type *VecTy = ReduxRoot->getOperand(0)->getType();
952 unsigned NumVecElems = VecTy->getVectorNumElements();
953 if (!isPowerOf2_32(NumVecElems))
954 return RK_None;
955
956 // We look for a sequence of shuffles and adds like the following matching one
957 // fadd, shuffle vector pair at a time.
Fangrui Songf78650a2018-07-30 19:41:25 +0000958 //
Guozhi Wei62d64142017-09-08 22:29:17 +0000959 // %rdx.shuf = shufflevector <4 x float> %rdx, <4 x float> undef,
960 // <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
961 // %bin.rdx = fadd <4 x float> %rdx, %rdx.shuf
962 // %rdx.shuf7 = shufflevector <4 x float> %bin.rdx, <4 x float> undef,
963 // <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
964 // %bin.rdx8 = fadd <4 x float> %bin.rdx, %rdx.shuf7
965 // %r = extractelement <4 x float> %bin.rdx8, i32 0
966
967 unsigned MaskStart = 1;
968 Instruction *RdxOp = RdxStart;
Fangrui Songf78650a2018-07-30 19:41:25 +0000969 SmallVector<int, 32> ShuffleMask(NumVecElems, 0);
Guozhi Wei62d64142017-09-08 22:29:17 +0000970 unsigned NumVecElemsRemain = NumVecElems;
971 while (NumVecElemsRemain - 1) {
972 // Check for the right reduction operation.
973 if (!RdxOp)
974 return RK_None;
975 Optional<ReductionData> RDLevel = getReductionData(RdxOp);
976 if (!RDLevel || !RDLevel->hasSameData(*RD))
977 return RK_None;
978
979 Value *NextRdxOp;
980 ShuffleVectorInst *Shuffle;
981 std::tie(NextRdxOp, Shuffle) =
982 getShuffleAndOtherOprd(RDLevel->LHS, RDLevel->RHS);
983
984 // Check the current reduction operation and the shuffle use the same value.
985 if (Shuffle == nullptr)
986 return RK_None;
987 if (Shuffle->getOperand(0) != NextRdxOp)
988 return RK_None;
989
990 // Check that shuffle masks matches.
991 for (unsigned j = 0; j != MaskStart; ++j)
992 ShuffleMask[j] = MaskStart + j;
993 // Fill the rest of the mask with -1 for undef.
994 std::fill(&ShuffleMask[MaskStart], ShuffleMask.end(), -1);
995
996 SmallVector<int, 16> Mask = Shuffle->getShuffleMask();
997 if (ShuffleMask != Mask)
998 return RK_None;
999
1000 RdxOp = dyn_cast<Instruction>(NextRdxOp);
1001 NumVecElemsRemain /= 2;
1002 MaskStart *= 2;
1003 }
1004
1005 Opcode = RD->Opcode;
1006 Ty = VecTy;
1007 return RD->Kind;
1008}
1009
1010int TargetTransformInfo::getInstructionThroughput(const Instruction *I) const {
1011 switch (I->getOpcode()) {
1012 case Instruction::GetElementPtr:
1013 return getUserCost(I);
1014
1015 case Instruction::Ret:
1016 case Instruction::PHI:
1017 case Instruction::Br: {
1018 return getCFInstrCost(I->getOpcode());
1019 }
1020 case Instruction::Add:
1021 case Instruction::FAdd:
1022 case Instruction::Sub:
1023 case Instruction::FSub:
1024 case Instruction::Mul:
1025 case Instruction::FMul:
1026 case Instruction::UDiv:
1027 case Instruction::SDiv:
1028 case Instruction::FDiv:
1029 case Instruction::URem:
1030 case Instruction::SRem:
1031 case Instruction::FRem:
1032 case Instruction::Shl:
1033 case Instruction::LShr:
1034 case Instruction::AShr:
1035 case Instruction::And:
1036 case Instruction::Or:
1037 case Instruction::Xor: {
Simon Pilgrim4162d772018-05-22 10:40:09 +00001038 TargetTransformInfo::OperandValueKind Op1VK, Op2VK;
1039 TargetTransformInfo::OperandValueProperties Op1VP, Op2VP;
1040 Op1VK = getOperandInfo(I->getOperand(0), Op1VP);
1041 Op2VK = getOperandInfo(I->getOperand(1), Op2VP);
1042 SmallVector<const Value *, 2> Operands(I->operand_values());
1043 return getArithmeticInstrCost(I->getOpcode(), I->getType(), Op1VK, Op2VK,
1044 Op1VP, Op2VP, Operands);
Guozhi Wei62d64142017-09-08 22:29:17 +00001045 }
1046 case Instruction::Select: {
1047 const SelectInst *SI = cast<SelectInst>(I);
1048 Type *CondTy = SI->getCondition()->getType();
1049 return getCmpSelInstrCost(I->getOpcode(), I->getType(), CondTy, I);
1050 }
1051 case Instruction::ICmp:
1052 case Instruction::FCmp: {
1053 Type *ValTy = I->getOperand(0)->getType();
1054 return getCmpSelInstrCost(I->getOpcode(), ValTy, I->getType(), I);
1055 }
1056 case Instruction::Store: {
1057 const StoreInst *SI = cast<StoreInst>(I);
1058 Type *ValTy = SI->getValueOperand()->getType();
1059 return getMemoryOpCost(I->getOpcode(), ValTy,
1060 SI->getAlignment(),
1061 SI->getPointerAddressSpace(), I);
1062 }
1063 case Instruction::Load: {
1064 const LoadInst *LI = cast<LoadInst>(I);
1065 return getMemoryOpCost(I->getOpcode(), I->getType(),
1066 LI->getAlignment(),
1067 LI->getPointerAddressSpace(), I);
1068 }
1069 case Instruction::ZExt:
1070 case Instruction::SExt:
1071 case Instruction::FPToUI:
1072 case Instruction::FPToSI:
1073 case Instruction::FPExt:
1074 case Instruction::PtrToInt:
1075 case Instruction::IntToPtr:
1076 case Instruction::SIToFP:
1077 case Instruction::UIToFP:
1078 case Instruction::Trunc:
1079 case Instruction::FPTrunc:
1080 case Instruction::BitCast:
1081 case Instruction::AddrSpaceCast: {
1082 Type *SrcTy = I->getOperand(0)->getType();
1083 return getCastInstrCost(I->getOpcode(), I->getType(), SrcTy, I);
1084 }
1085 case Instruction::ExtractElement: {
1086 const ExtractElementInst * EEI = cast<ExtractElementInst>(I);
1087 ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1));
1088 unsigned Idx = -1;
1089 if (CI)
1090 Idx = CI->getZExtValue();
1091
1092 // Try to match a reduction sequence (series of shufflevector and vector
1093 // adds followed by a extractelement).
1094 unsigned ReduxOpCode;
1095 Type *ReduxType;
1096
1097 switch (matchVectorSplittingReduction(EEI, ReduxOpCode, ReduxType)) {
1098 case RK_Arithmetic:
1099 return getArithmeticReductionCost(ReduxOpCode, ReduxType,
1100 /*IsPairwiseForm=*/false);
1101 case RK_MinMax:
1102 return getMinMaxReductionCost(
1103 ReduxType, CmpInst::makeCmpResultType(ReduxType),
1104 /*IsPairwiseForm=*/false, /*IsUnsigned=*/false);
1105 case RK_UnsignedMinMax:
1106 return getMinMaxReductionCost(
1107 ReduxType, CmpInst::makeCmpResultType(ReduxType),
1108 /*IsPairwiseForm=*/false, /*IsUnsigned=*/true);
1109 case RK_None:
1110 break;
1111 }
1112
1113 switch (matchPairwiseReduction(EEI, ReduxOpCode, ReduxType)) {
1114 case RK_Arithmetic:
1115 return getArithmeticReductionCost(ReduxOpCode, ReduxType,
1116 /*IsPairwiseForm=*/true);
1117 case RK_MinMax:
1118 return getMinMaxReductionCost(
1119 ReduxType, CmpInst::makeCmpResultType(ReduxType),
1120 /*IsPairwiseForm=*/true, /*IsUnsigned=*/false);
1121 case RK_UnsignedMinMax:
1122 return getMinMaxReductionCost(
1123 ReduxType, CmpInst::makeCmpResultType(ReduxType),
1124 /*IsPairwiseForm=*/true, /*IsUnsigned=*/true);
1125 case RK_None:
1126 break;
1127 }
1128
1129 return getVectorInstrCost(I->getOpcode(),
1130 EEI->getOperand(0)->getType(), Idx);
1131 }
1132 case Instruction::InsertElement: {
1133 const InsertElementInst * IE = cast<InsertElementInst>(I);
1134 ConstantInt *CI = dyn_cast<ConstantInt>(IE->getOperand(2));
Fangrui Songf78650a2018-07-30 19:41:25 +00001135 unsigned Idx = -1;
Guozhi Wei62d64142017-09-08 22:29:17 +00001136 if (CI)
1137 Idx = CI->getZExtValue();
1138 return getVectorInstrCost(I->getOpcode(),
1139 IE->getType(), Idx);
1140 }
1141 case Instruction::ShuffleVector: {
1142 const ShuffleVectorInst *Shuffle = cast<ShuffleVectorInst>(I);
Simon Pilgrimd0c71602018-11-09 16:28:19 +00001143 Type *Ty = Shuffle->getType();
1144 Type *SrcTy = Shuffle->getOperand(0)->getType();
1145
1146 // TODO: Identify and add costs for insert subvector, etc.
1147 int SubIndex;
1148 if (Shuffle->isExtractSubvectorMask(SubIndex))
Simon Pilgrim26e1c882018-11-09 18:30:59 +00001149 return TTIImpl->getShuffleCost(SK_ExtractSubvector, SrcTy, SubIndex, Ty);
Simon Pilgrimd0c71602018-11-09 16:28:19 +00001150
Sanjay Patel2ca33602018-06-19 18:44:00 +00001151 if (Shuffle->changesLength())
1152 return -1;
Fangrui Songf78650a2018-07-30 19:41:25 +00001153
Sanjay Patel2ca33602018-06-19 18:44:00 +00001154 if (Shuffle->isIdentity())
1155 return 0;
Guozhi Wei62d64142017-09-08 22:29:17 +00001156
Sanjay Patel2ca33602018-06-19 18:44:00 +00001157 if (Shuffle->isReverse())
1158 return TTIImpl->getShuffleCost(SK_Reverse, Ty, 0, nullptr);
Simon Pilgrim07839212018-06-12 14:47:13 +00001159
Sanjay Patel2ca33602018-06-19 18:44:00 +00001160 if (Shuffle->isSelect())
1161 return TTIImpl->getShuffleCost(SK_Select, Ty, 0, nullptr);
Simon Pilgrim07839212018-06-12 14:47:13 +00001162
Sanjay Patel2ca33602018-06-19 18:44:00 +00001163 if (Shuffle->isTranspose())
1164 return TTIImpl->getShuffleCost(SK_Transpose, Ty, 0, nullptr);
Matthew Simpsonb4096eb2018-04-26 13:48:33 +00001165
Sanjay Patel2ca33602018-06-19 18:44:00 +00001166 if (Shuffle->isZeroEltSplat())
1167 return TTIImpl->getShuffleCost(SK_Broadcast, Ty, 0, nullptr);
Guozhi Wei62d64142017-09-08 22:29:17 +00001168
Sanjay Patel2ca33602018-06-19 18:44:00 +00001169 if (Shuffle->isSingleSource())
1170 return TTIImpl->getShuffleCost(SK_PermuteSingleSrc, Ty, 0, nullptr);
Guozhi Wei62d64142017-09-08 22:29:17 +00001171
Sanjay Patel2ca33602018-06-19 18:44:00 +00001172 return TTIImpl->getShuffleCost(SK_PermuteTwoSrc, Ty, 0, nullptr);
Guozhi Wei62d64142017-09-08 22:29:17 +00001173 }
1174 case Instruction::Call:
1175 if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
1176 SmallVector<Value *, 4> Args(II->arg_operands());
1177
1178 FastMathFlags FMF;
1179 if (auto *FPMO = dyn_cast<FPMathOperator>(II))
1180 FMF = FPMO->getFastMathFlags();
1181
1182 return getIntrinsicInstrCost(II->getIntrinsicID(), II->getType(),
1183 Args, FMF);
1184 }
1185 return -1;
1186 default:
1187 // We don't have any information on this instruction.
1188 return -1;
1189 }
1190}
1191
Chandler Carruth705b1852015-01-31 03:43:40 +00001192TargetTransformInfo::Concept::~Concept() {}
1193
Chandler Carruthe0385522015-02-01 10:11:22 +00001194TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
1195
1196TargetIRAnalysis::TargetIRAnalysis(
Eric Christophera4e5d3c2015-09-16 23:38:13 +00001197 std::function<Result(const Function &)> TTICallback)
Benjamin Kramer82de7d32016-05-27 14:27:24 +00001198 : TTICallback(std::move(TTICallback)) {}
Chandler Carruthe0385522015-02-01 10:11:22 +00001199
Chandler Carruth164a2aa62016-06-17 00:11:01 +00001200TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F,
Sean Silva36e0d012016-08-09 00:28:15 +00001201 FunctionAnalysisManager &) {
Chandler Carruthe0385522015-02-01 10:11:22 +00001202 return TTICallback(F);
1203}
1204
Chandler Carruthdab4eae2016-11-23 17:53:26 +00001205AnalysisKey TargetIRAnalysis::Key;
NAKAMURA Takumidf0cd722016-02-28 17:17:00 +00001206
Eric Christophera4e5d3c2015-09-16 23:38:13 +00001207TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
Mehdi Amini5010ebf2015-07-09 02:08:42 +00001208 return Result(F.getParent()->getDataLayout());
Chandler Carruthe0385522015-02-01 10:11:22 +00001209}
1210
Chandler Carruth705b1852015-01-31 03:43:40 +00001211// Register the basic pass.
1212INITIALIZE_PASS(TargetTransformInfoWrapperPass, "tti",
1213 "Target Transform Information", false, true)
1214char TargetTransformInfoWrapperPass::ID = 0;
Chandler Carruth539edf42013-01-05 11:43:11 +00001215
Chandler Carruth705b1852015-01-31 03:43:40 +00001216void TargetTransformInfoWrapperPass::anchor() {}
Chandler Carruth539edf42013-01-05 11:43:11 +00001217
Chandler Carruth705b1852015-01-31 03:43:40 +00001218TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +00001219 : ImmutablePass(ID) {
Chandler Carruth705b1852015-01-31 03:43:40 +00001220 initializeTargetTransformInfoWrapperPassPass(
1221 *PassRegistry::getPassRegistry());
1222}
1223
1224TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +00001225 TargetIRAnalysis TIRA)
1226 : ImmutablePass(ID), TIRA(std::move(TIRA)) {
Chandler Carruth705b1852015-01-31 03:43:40 +00001227 initializeTargetTransformInfoWrapperPassPass(
1228 *PassRegistry::getPassRegistry());
1229}
1230
Eric Christophera4e5d3c2015-09-16 23:38:13 +00001231TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
Sean Silva36e0d012016-08-09 00:28:15 +00001232 FunctionAnalysisManager DummyFAM;
Chandler Carruth164a2aa62016-06-17 00:11:01 +00001233 TTI = TIRA.run(F, DummyFAM);
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +00001234 return *TTI;
1235}
1236
Chandler Carruth93dcdc42015-01-31 11:17:59 +00001237ImmutablePass *
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +00001238llvm::createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA) {
1239 return new TargetTransformInfoWrapperPass(std::move(TIRA));
Chandler Carruth539edf42013-01-05 11:43:11 +00001240}