blob: dc08a3b0e146b7c1ee2686eb87f86b03d3c72bde [file] [log] [blame]
Chandler Carruth664e3542013-01-07 01:37:14 +00001//===-- X86TargetTransformInfo.cpp - X86 specific TTI pass ----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9/// \file
10/// This file implements a TargetTransformInfo analysis pass specific to the
11/// X86 target machine. It uses the target's detailed information to provide
12/// more precise answers to certain TTI queries, while letting the target
13/// independent and default TTI implementations handle the rest.
14///
15//===----------------------------------------------------------------------===//
16
Chandler Carruth664e3542013-01-07 01:37:14 +000017#include "X86.h"
18#include "X86TargetMachine.h"
Chandler Carruthd3e73552013-01-07 03:08:10 +000019#include "llvm/Analysis/TargetTransformInfo.h"
Juergen Ributzkaf26beda2014-01-25 02:02:55 +000020#include "llvm/IR/IntrinsicInst.h"
Chandler Carruth664e3542013-01-07 01:37:14 +000021#include "llvm/Support/Debug.h"
Renato Golind4c392e2013-01-24 23:01:00 +000022#include "llvm/Target/CostTable.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000023#include "llvm/Target/TargetLowering.h"
Chandler Carruth664e3542013-01-07 01:37:14 +000024using namespace llvm;
25
Chandler Carruth84e68b22014-04-22 02:41:26 +000026#define DEBUG_TYPE "x86tti"
27
Chandler Carruth664e3542013-01-07 01:37:14 +000028// Declare the pass initialization routine locally as target-specific passes
Eric Christopher89f18802014-05-22 01:21:44 +000029// don't have a target-wide initialization entry point, and so we rely on the
Chandler Carruth664e3542013-01-07 01:37:14 +000030// pass constructor initialization.
31namespace llvm {
32void initializeX86TTIPass(PassRegistry &);
33}
34
35namespace {
36
Craig Topper77dfe452014-03-02 08:08:51 +000037class X86TTI final : public ImmutablePass, public TargetTransformInfo {
Chandler Carruth664e3542013-01-07 01:37:14 +000038 const X86Subtarget *ST;
39 const X86TargetLowering *TLI;
40
41 /// Estimate the overhead of scalarizing an instruction. Insert and Extract
42 /// are set if the result needs to be inserted and/or extracted from vectors.
43 unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const;
44
45public:
Craig Topper062a2ba2014-04-25 05:30:21 +000046 X86TTI() : ImmutablePass(ID), ST(nullptr), TLI(nullptr) {
Chandler Carruth664e3542013-01-07 01:37:14 +000047 llvm_unreachable("This pass cannot be directly constructed");
48 }
49
50 X86TTI(const X86TargetMachine *TM)
Eric Christopherd9134482014-08-04 21:25:23 +000051 : ImmutablePass(ID), ST(TM->getSubtargetImpl()),
52 TLI(TM->getSubtargetImpl()->getTargetLowering()) {
Chandler Carruth664e3542013-01-07 01:37:14 +000053 initializeX86TTIPass(*PassRegistry::getPassRegistry());
54 }
55
Craig Topper24e685f2014-03-10 05:29:18 +000056 void initializePass() override {
Chandler Carruth664e3542013-01-07 01:37:14 +000057 pushTTIStack(this);
58 }
59
Craig Topper24e685f2014-03-10 05:29:18 +000060 void getAnalysisUsage(AnalysisUsage &AU) const override {
Chandler Carruth664e3542013-01-07 01:37:14 +000061 TargetTransformInfo::getAnalysisUsage(AU);
62 }
63
64 /// Pass identification.
65 static char ID;
66
67 /// Provide necessary pointer adjustments for the two base classes.
Craig Topper24e685f2014-03-10 05:29:18 +000068 void *getAdjustedAnalysisPointer(const void *ID) override {
Chandler Carruth664e3542013-01-07 01:37:14 +000069 if (ID == &TargetTransformInfo::ID)
70 return (TargetTransformInfo*)this;
71 return this;
72 }
73
74 /// \name Scalar TTI Implementations
75 /// @{
Craig Topper24e685f2014-03-10 05:29:18 +000076 PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;
Chandler Carruth664e3542013-01-07 01:37:14 +000077
78 /// @}
79
80 /// \name Vector TTI Implementations
81 /// @{
82
Craig Topper24e685f2014-03-10 05:29:18 +000083 unsigned getNumberOfRegisters(bool Vector) const override;
84 unsigned getRegisterBitWidth(bool Vector) const override;
Sanjay Patelb653de12014-09-10 17:58:16 +000085 unsigned getMaxInterleaveFactor() const override;
Craig Topper24e685f2014-03-10 05:29:18 +000086 unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind,
Karthik Bhat7f33ff72014-08-25 04:56:54 +000087 OperandValueKind, OperandValueProperties,
88 OperandValueProperties) const override;
Craig Topper24e685f2014-03-10 05:29:18 +000089 unsigned getShuffleCost(ShuffleKind Kind, Type *Tp,
90 int Index, Type *SubTp) const override;
91 unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
92 Type *Src) const override;
93 unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
94 Type *CondTy) const override;
95 unsigned getVectorInstrCost(unsigned Opcode, Type *Val,
96 unsigned Index) const override;
97 unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
98 unsigned AddressSpace) const override;
Chandler Carruth664e3542013-01-07 01:37:14 +000099
Craig Topper24e685f2014-03-10 05:29:18 +0000100 unsigned getAddressComputationCost(Type *PtrTy,
101 bool IsComplex) const override;
Arnold Schwaighofer6042a262013-07-12 19:16:07 +0000102
Craig Topper24e685f2014-03-10 05:29:18 +0000103 unsigned getReductionCost(unsigned Opcode, Type *Ty,
104 bool IsPairwiseForm) const override;
Craig Topper73156022014-03-02 09:09:27 +0000105
Juergen Ributzkab2e4edb2014-06-10 00:32:29 +0000106 unsigned getIntImmCost(int64_t) const;
107
Craig Topper24e685f2014-03-10 05:29:18 +0000108 unsigned getIntImmCost(const APInt &Imm, Type *Ty) const override;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +0000109
Juergen Ributzkaf0dff492014-03-21 06:04:45 +0000110 unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
Craig Topper24e685f2014-03-10 05:29:18 +0000111 Type *Ty) const override;
Juergen Ributzkaf0dff492014-03-21 06:04:45 +0000112 unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
Craig Topper24e685f2014-03-10 05:29:18 +0000113 Type *Ty) const override;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +0000114
Chandler Carruth664e3542013-01-07 01:37:14 +0000115 /// @}
116};
117
118} // end anonymous namespace
119
120INITIALIZE_AG_PASS(X86TTI, TargetTransformInfo, "x86tti",
121 "X86 Target Transform Info", true, true, false)
122char X86TTI::ID = 0;
123
124ImmutablePass *
125llvm::createX86TargetTransformInfoPass(const X86TargetMachine *TM) {
126 return new X86TTI(TM);
127}
128
129
130//===----------------------------------------------------------------------===//
131//
132// X86 cost model.
133//
134//===----------------------------------------------------------------------===//
135
Chandler Carruth50a36cd2013-01-07 03:16:03 +0000136X86TTI::PopcntSupportKind X86TTI::getPopcntSupport(unsigned TyWidth) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000137 assert(isPowerOf2_32(TyWidth) && "Ty width must be power of 2");
138 // TODO: Currently the __builtin_popcount() implementation using SSE3
139 // instructions is inefficient. Once the problem is fixed, we should
Craig Topper0a63e1d2013-09-08 00:47:31 +0000140 // call ST->hasSSE3() instead of ST->hasPOPCNT().
141 return ST->hasPOPCNT() ? PSK_FastHardware : PSK_Software;
Chandler Carruth664e3542013-01-07 01:37:14 +0000142}
143
144unsigned X86TTI::getNumberOfRegisters(bool Vector) const {
Nadav Rotemb1791a72013-01-09 22:29:00 +0000145 if (Vector && !ST->hasSSE1())
146 return 0;
147
Adam Nemet2820a5b2014-07-09 18:22:33 +0000148 if (ST->is64Bit()) {
149 if (Vector && ST->hasAVX512())
150 return 32;
Chandler Carruth664e3542013-01-07 01:37:14 +0000151 return 16;
Adam Nemet2820a5b2014-07-09 18:22:33 +0000152 }
Chandler Carruth664e3542013-01-07 01:37:14 +0000153 return 8;
154}
155
Nadav Rotemb1791a72013-01-09 22:29:00 +0000156unsigned X86TTI::getRegisterBitWidth(bool Vector) const {
157 if (Vector) {
Adam Nemet2820a5b2014-07-09 18:22:33 +0000158 if (ST->hasAVX512()) return 512;
Nadav Rotemb1791a72013-01-09 22:29:00 +0000159 if (ST->hasAVX()) return 256;
160 if (ST->hasSSE1()) return 128;
161 return 0;
162 }
163
164 if (ST->is64Bit())
165 return 64;
166 return 32;
167
168}
169
Sanjay Patelb653de12014-09-10 17:58:16 +0000170unsigned X86TTI::getMaxInterleaveFactor() const {
Nadav Rotemb696c362013-01-09 01:15:42 +0000171 if (ST->isAtom())
172 return 1;
173
174 // Sandybridge and Haswell have multiple execution ports and pipelined
175 // vector units.
176 if (ST->hasAVX())
177 return 4;
178
179 return 2;
180}
181
Karthik Bhat7f33ff72014-08-25 04:56:54 +0000182unsigned X86TTI::getArithmeticInstrCost(
183 unsigned Opcode, Type *Ty, OperandValueKind Op1Info,
184 OperandValueKind Op2Info, OperandValueProperties Opd1PropInfo,
185 OperandValueProperties Opd2PropInfo) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000186 // Legalize the type.
187 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty);
188
189 int ISD = TLI->InstructionOpcodeToISD(Opcode);
190 assert(ISD && "Invalid opcode");
191
Karthik Bhat7f33ff72014-08-25 04:56:54 +0000192 if (ISD == ISD::SDIV &&
193 Op2Info == TargetTransformInfo::OK_UniformConstantValue &&
194 Opd2PropInfo == TargetTransformInfo::OP_PowerOf2) {
195 // On X86, vector signed division by constants power-of-two are
196 // normally expanded to the sequence SRA + SRL + ADD + SRA.
197 // The OperandValue properties many not be same as that of previous
198 // operation;conservatively assume OP_None.
199 unsigned Cost =
200 2 * getArithmeticInstrCost(Instruction::AShr, Ty, Op1Info, Op2Info,
201 TargetTransformInfo::OP_None,
202 TargetTransformInfo::OP_None);
203 Cost += getArithmeticInstrCost(Instruction::LShr, Ty, Op1Info, Op2Info,
204 TargetTransformInfo::OP_None,
205 TargetTransformInfo::OP_None);
206 Cost += getArithmeticInstrCost(Instruction::Add, Ty, Op1Info, Op2Info,
207 TargetTransformInfo::OP_None,
208 TargetTransformInfo::OP_None);
209
210 return Cost;
211 }
212
Benjamin Kramer7c372272014-04-26 14:53:05 +0000213 static const CostTblEntry<MVT::SimpleValueType>
214 AVX2UniformConstCostTable[] = {
215 { ISD::SDIV, MVT::v16i16, 6 }, // vpmulhw sequence
216 { ISD::UDIV, MVT::v16i16, 6 }, // vpmulhuw sequence
217 { ISD::SDIV, MVT::v8i32, 15 }, // vpmuldq sequence
218 { ISD::UDIV, MVT::v8i32, 15 }, // vpmuludq sequence
219 };
220
221 if (Op2Info == TargetTransformInfo::OK_UniformConstantValue &&
222 ST->hasAVX2()) {
223 int Idx = CostTableLookup(AVX2UniformConstCostTable, ISD, LT.second);
224 if (Idx != -1)
225 return LT.first * AVX2UniformConstCostTable[Idx].Cost;
226 }
227
Elena Demikhovsky27012472014-09-16 07:57:37 +0000228 static const CostTblEntry<MVT::SimpleValueType> AVX512CostTable[] = {
229 { ISD::SHL, MVT::v16i32, 1 },
230 { ISD::SRL, MVT::v16i32, 1 },
231 { ISD::SRA, MVT::v16i32, 1 },
232 { ISD::SHL, MVT::v8i64, 1 },
233 { ISD::SRL, MVT::v8i64, 1 },
234 { ISD::SRA, MVT::v8i64, 1 },
235 };
236
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000237 static const CostTblEntry<MVT::SimpleValueType> AVX2CostTable[] = {
Michael Liao70dd7f92013-03-20 22:01:10 +0000238 // Shifts on v4i64/v8i32 on AVX2 is legal even though we declare to
239 // customize them to detect the cases where shift amount is a scalar one.
240 { ISD::SHL, MVT::v4i32, 1 },
241 { ISD::SRL, MVT::v4i32, 1 },
242 { ISD::SRA, MVT::v4i32, 1 },
243 { ISD::SHL, MVT::v8i32, 1 },
244 { ISD::SRL, MVT::v8i32, 1 },
245 { ISD::SRA, MVT::v8i32, 1 },
246 { ISD::SHL, MVT::v2i64, 1 },
247 { ISD::SRL, MVT::v2i64, 1 },
248 { ISD::SHL, MVT::v4i64, 1 },
249 { ISD::SRL, MVT::v4i64, 1 },
Arnold Schwaighofere9b50162013-04-03 21:46:05 +0000250
251 { ISD::SHL, MVT::v32i8, 42 }, // cmpeqb sequence.
252 { ISD::SHL, MVT::v16i16, 16*10 }, // Scalarized.
253
254 { ISD::SRL, MVT::v32i8, 32*10 }, // Scalarized.
255 { ISD::SRL, MVT::v16i16, 8*10 }, // Scalarized.
256
257 { ISD::SRA, MVT::v32i8, 32*10 }, // Scalarized.
258 { ISD::SRA, MVT::v16i16, 16*10 }, // Scalarized.
259 { ISD::SRA, MVT::v4i64, 4*10 }, // Scalarized.
Arnold Schwaighofera04b9ef2013-06-25 19:14:09 +0000260
261 // Vectorizing division is a bad idea. See the SSE2 table for more comments.
262 { ISD::SDIV, MVT::v32i8, 32*20 },
263 { ISD::SDIV, MVT::v16i16, 16*20 },
264 { ISD::SDIV, MVT::v8i32, 8*20 },
265 { ISD::SDIV, MVT::v4i64, 4*20 },
266 { ISD::UDIV, MVT::v32i8, 32*20 },
267 { ISD::UDIV, MVT::v16i16, 16*20 },
268 { ISD::UDIV, MVT::v8i32, 8*20 },
269 { ISD::UDIV, MVT::v4i64, 4*20 },
Michael Liao70dd7f92013-03-20 22:01:10 +0000270 };
271
Elena Demikhovsky27012472014-09-16 07:57:37 +0000272 if (ST->hasAVX512()) {
273 int Idx = CostTableLookup(AVX512CostTable, ISD, LT.second);
274 if (Idx != -1)
275 return LT.first * AVX512CostTable[Idx].Cost;
276 }
Michael Liao70dd7f92013-03-20 22:01:10 +0000277 // Look for AVX2 lowering tricks.
278 if (ST->hasAVX2()) {
Andrea Di Biagiob7882b32014-02-12 23:43:47 +0000279 if (ISD == ISD::SHL && LT.second == MVT::v16i16 &&
280 (Op2Info == TargetTransformInfo::OK_UniformConstantValue ||
281 Op2Info == TargetTransformInfo::OK_NonUniformConstantValue))
282 // On AVX2, a packed v16i16 shift left by a constant build_vector
283 // is lowered into a vector multiply (vpmullw).
284 return LT.first;
285
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000286 int Idx = CostTableLookup(AVX2CostTable, ISD, LT.second);
Michael Liao70dd7f92013-03-20 22:01:10 +0000287 if (Idx != -1)
288 return LT.first * AVX2CostTable[Idx].Cost;
289 }
290
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000291 static const CostTblEntry<MVT::SimpleValueType>
292 SSE2UniformConstCostTable[] = {
Arnold Schwaighofer44f902e2013-04-04 23:26:24 +0000293 // We don't correctly identify costs of casts because they are marked as
294 // custom.
295 // Constant splats are cheaper for the following instructions.
296 { ISD::SHL, MVT::v16i8, 1 }, // psllw.
297 { ISD::SHL, MVT::v8i16, 1 }, // psllw.
298 { ISD::SHL, MVT::v4i32, 1 }, // pslld
299 { ISD::SHL, MVT::v2i64, 1 }, // psllq.
300
301 { ISD::SRL, MVT::v16i8, 1 }, // psrlw.
302 { ISD::SRL, MVT::v8i16, 1 }, // psrlw.
303 { ISD::SRL, MVT::v4i32, 1 }, // psrld.
304 { ISD::SRL, MVT::v2i64, 1 }, // psrlq.
305
306 { ISD::SRA, MVT::v16i8, 4 }, // psrlw, pand, pxor, psubb.
307 { ISD::SRA, MVT::v8i16, 1 }, // psraw.
308 { ISD::SRA, MVT::v4i32, 1 }, // psrad.
Benjamin Kramer7c372272014-04-26 14:53:05 +0000309
310 { ISD::SDIV, MVT::v8i16, 6 }, // pmulhw sequence
311 { ISD::UDIV, MVT::v8i16, 6 }, // pmulhuw sequence
Benjamin Kramerce4b3fe2014-04-27 18:47:54 +0000312 { ISD::SDIV, MVT::v4i32, 19 }, // pmuludq sequence
Benjamin Kramer7c372272014-04-26 14:53:05 +0000313 { ISD::UDIV, MVT::v4i32, 15 }, // pmuludq sequence
Arnold Schwaighofer44f902e2013-04-04 23:26:24 +0000314 };
315
316 if (Op2Info == TargetTransformInfo::OK_UniformConstantValue &&
317 ST->hasSSE2()) {
Benjamin Kramerce4b3fe2014-04-27 18:47:54 +0000318 // pmuldq sequence.
319 if (ISD == ISD::SDIV && LT.second == MVT::v4i32 && ST->hasSSE41())
320 return LT.first * 15;
321
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000322 int Idx = CostTableLookup(SSE2UniformConstCostTable, ISD, LT.second);
Arnold Schwaighofer44f902e2013-04-04 23:26:24 +0000323 if (Idx != -1)
324 return LT.first * SSE2UniformConstCostTable[Idx].Cost;
325 }
326
Andrea Di Biagiob7882b32014-02-12 23:43:47 +0000327 if (ISD == ISD::SHL &&
328 Op2Info == TargetTransformInfo::OK_NonUniformConstantValue) {
329 EVT VT = LT.second;
330 if ((VT == MVT::v8i16 && ST->hasSSE2()) ||
331 (VT == MVT::v4i32 && ST->hasSSE41()))
332 // Vector shift left by non uniform constant can be lowered
333 // into vector multiply (pmullw/pmulld).
334 return LT.first;
335 if (VT == MVT::v4i32 && ST->hasSSE2())
336 // A vector shift left by non uniform constant is converted
337 // into a vector multiply; the new multiply is eventually
338 // lowered into a sequence of shuffles and 2 x pmuludq.
339 ISD = ISD::MUL;
340 }
Arnold Schwaighofer44f902e2013-04-04 23:26:24 +0000341
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000342 static const CostTblEntry<MVT::SimpleValueType> SSE2CostTable[] = {
Arnold Schwaighofere9b50162013-04-03 21:46:05 +0000343 // We don't correctly identify costs of casts because they are marked as
344 // custom.
345 // For some cases, where the shift amount is a scalar we would be able
346 // to generate better code. Unfortunately, when this is the case the value
347 // (the splat) will get hoisted out of the loop, thereby making it invisible
348 // to ISel. The cost model must return worst case assumptions because it is
349 // used for vectorization and we don't want to make vectorized code worse
350 // than scalar code.
351 { ISD::SHL, MVT::v16i8, 30 }, // cmpeqb sequence.
352 { ISD::SHL, MVT::v8i16, 8*10 }, // Scalarized.
353 { ISD::SHL, MVT::v4i32, 2*5 }, // We optimized this using mul.
354 { ISD::SHL, MVT::v2i64, 2*10 }, // Scalarized.
Andrea Di Biagiob7882b32014-02-12 23:43:47 +0000355 { ISD::SHL, MVT::v4i64, 4*10 }, // Scalarized.
Arnold Schwaighofere9b50162013-04-03 21:46:05 +0000356
357 { ISD::SRL, MVT::v16i8, 16*10 }, // Scalarized.
358 { ISD::SRL, MVT::v8i16, 8*10 }, // Scalarized.
359 { ISD::SRL, MVT::v4i32, 4*10 }, // Scalarized.
360 { ISD::SRL, MVT::v2i64, 2*10 }, // Scalarized.
361
362 { ISD::SRA, MVT::v16i8, 16*10 }, // Scalarized.
363 { ISD::SRA, MVT::v8i16, 8*10 }, // Scalarized.
364 { ISD::SRA, MVT::v4i32, 4*10 }, // Scalarized.
365 { ISD::SRA, MVT::v2i64, 2*10 }, // Scalarized.
Arnold Schwaighofera04b9ef2013-06-25 19:14:09 +0000366
367 // It is not a good idea to vectorize division. We have to scalarize it and
368 // in the process we will often end up having to spilling regular
369 // registers. The overhead of division is going to dominate most kernels
370 // anyways so try hard to prevent vectorization of division - it is
371 // generally a bad idea. Assume somewhat arbitrarily that we have to be able
372 // to hide "20 cycles" for each lane.
373 { ISD::SDIV, MVT::v16i8, 16*20 },
374 { ISD::SDIV, MVT::v8i16, 8*20 },
375 { ISD::SDIV, MVT::v4i32, 4*20 },
376 { ISD::SDIV, MVT::v2i64, 2*20 },
377 { ISD::UDIV, MVT::v16i8, 16*20 },
378 { ISD::UDIV, MVT::v8i16, 8*20 },
379 { ISD::UDIV, MVT::v4i32, 4*20 },
380 { ISD::UDIV, MVT::v2i64, 2*20 },
Arnold Schwaighofere9b50162013-04-03 21:46:05 +0000381 };
382
383 if (ST->hasSSE2()) {
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000384 int Idx = CostTableLookup(SSE2CostTable, ISD, LT.second);
Arnold Schwaighofere9b50162013-04-03 21:46:05 +0000385 if (Idx != -1)
386 return LT.first * SSE2CostTable[Idx].Cost;
387 }
388
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000389 static const CostTblEntry<MVT::SimpleValueType> AVX1CostTable[] = {
Renato Goline1fb0592013-01-20 20:57:20 +0000390 // We don't have to scalarize unsupported ops. We can issue two half-sized
391 // operations and we only need to extract the upper YMM half.
392 // Two ops + 1 extract + 1 insert = 4.
Andrea Di Biagiob7882b32014-02-12 23:43:47 +0000393 { ISD::MUL, MVT::v16i16, 4 },
Renato Goline1fb0592013-01-20 20:57:20 +0000394 { ISD::MUL, MVT::v8i32, 4 },
395 { ISD::SUB, MVT::v8i32, 4 },
396 { ISD::ADD, MVT::v8i32, 4 },
Renato Goline1fb0592013-01-20 20:57:20 +0000397 { ISD::SUB, MVT::v4i64, 4 },
398 { ISD::ADD, MVT::v4i64, 4 },
Arnold Schwaighofer20ef54f2013-03-02 04:02:52 +0000399 // A v4i64 multiply is custom lowered as two split v2i64 vectors that then
400 // are lowered as a series of long multiplies(3), shifts(4) and adds(2)
401 // Because we believe v4i64 to be a legal type, we must also include the
402 // split factor of two in the cost table. Therefore, the cost here is 18
403 // instead of 9.
404 { ISD::MUL, MVT::v4i64, 18 },
405 };
Chandler Carruth664e3542013-01-07 01:37:14 +0000406
407 // Look for AVX1 lowering tricks.
Arnold Schwaighofer20ef54f2013-03-02 04:02:52 +0000408 if (ST->hasAVX() && !ST->hasAVX2()) {
Andrea Di Biagiob7882b32014-02-12 23:43:47 +0000409 EVT VT = LT.second;
410
411 // v16i16 and v8i32 shifts by non-uniform constants are lowered into a
412 // sequence of extract + two vector multiply + insert.
413 if (ISD == ISD::SHL && (VT == MVT::v8i32 || VT == MVT::v16i16) &&
414 Op2Info == TargetTransformInfo::OK_NonUniformConstantValue)
415 ISD = ISD::MUL;
416
417 int Idx = CostTableLookup(AVX1CostTable, ISD, VT);
Renato Goline1fb0592013-01-20 20:57:20 +0000418 if (Idx != -1)
419 return LT.first * AVX1CostTable[Idx].Cost;
Chandler Carruth664e3542013-01-07 01:37:14 +0000420 }
Arnold Schwaighofer20ef54f2013-03-02 04:02:52 +0000421
422 // Custom lowering of vectors.
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000423 static const CostTblEntry<MVT::SimpleValueType> CustomLowered[] = {
Arnold Schwaighofer20ef54f2013-03-02 04:02:52 +0000424 // A v2i64/v4i64 and multiply is custom lowered as a series of long
425 // multiplies(3), shifts(4) and adds(2).
426 { ISD::MUL, MVT::v2i64, 9 },
427 { ISD::MUL, MVT::v4i64, 9 },
428 };
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000429 int Idx = CostTableLookup(CustomLowered, ISD, LT.second);
Arnold Schwaighofer20ef54f2013-03-02 04:02:52 +0000430 if (Idx != -1)
431 return LT.first * CustomLowered[Idx].Cost;
432
433 // Special lowering of v4i32 mul on sse2, sse3: Lower v4i32 mul as 2x shuffle,
434 // 2x pmuludq, 2x shuffle.
435 if (ISD == ISD::MUL && LT.second == MVT::v4i32 && ST->hasSSE2() &&
436 !ST->hasSSE41())
Andrea Di Biagiob7882b32014-02-12 23:43:47 +0000437 return LT.first * 6;
Arnold Schwaighofer20ef54f2013-03-02 04:02:52 +0000438
Chandler Carruth664e3542013-01-07 01:37:14 +0000439 // Fallback to the default implementation.
Arnold Schwaighoferb9773872013-04-04 23:26:21 +0000440 return TargetTransformInfo::getArithmeticInstrCost(Opcode, Ty, Op1Info,
441 Op2Info);
Chandler Carruth664e3542013-01-07 01:37:14 +0000442}
443
444unsigned X86TTI::getShuffleCost(ShuffleKind Kind, Type *Tp, int Index,
445 Type *SubTp) const {
Karthik Bhate03a25d2014-06-20 04:32:48 +0000446 // We only estimate the cost of reverse and alternate shuffles.
447 if (Kind != SK_Reverse && Kind != SK_Alternate)
Chandler Carruth664e3542013-01-07 01:37:14 +0000448 return TargetTransformInfo::getShuffleCost(Kind, Tp, Index, SubTp);
449
Karthik Bhate03a25d2014-06-20 04:32:48 +0000450 if (Kind == SK_Reverse) {
451 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Tp);
452 unsigned Cost = 1;
453 if (LT.second.getSizeInBits() > 128)
454 Cost = 3; // Extract + insert + copy.
Chandler Carruth664e3542013-01-07 01:37:14 +0000455
Karthik Bhate03a25d2014-06-20 04:32:48 +0000456 // Multiple by the number of parts.
457 return Cost * LT.first;
458 }
459
460 if (Kind == SK_Alternate) {
Andrea Di Biagioc8e8bda2014-07-03 22:24:18 +0000461 // 64-bit packed float vectors (v2f32) are widened to type v4f32.
462 // 64-bit packed integer vectors (v2i32) are promoted to type v2i64.
Karthik Bhate03a25d2014-06-20 04:32:48 +0000463 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Tp);
464
Andrea Di Biagioc8e8bda2014-07-03 22:24:18 +0000465 // The backend knows how to generate a single VEX.256 version of
466 // instruction VPBLENDW if the target supports AVX2.
467 if (ST->hasAVX2() && LT.second == MVT::v16i16)
468 return LT.first;
469
470 static const CostTblEntry<MVT::SimpleValueType> AVXAltShuffleTbl[] = {
471 {ISD::VECTOR_SHUFFLE, MVT::v4i64, 1}, // vblendpd
472 {ISD::VECTOR_SHUFFLE, MVT::v4f64, 1}, // vblendpd
473
474 {ISD::VECTOR_SHUFFLE, MVT::v8i32, 1}, // vblendps
475 {ISD::VECTOR_SHUFFLE, MVT::v8f32, 1}, // vblendps
476
477 // This shuffle is custom lowered into a sequence of:
478 // 2x vextractf128 , 2x vpblendw , 1x vinsertf128
479 {ISD::VECTOR_SHUFFLE, MVT::v16i16, 5},
480
481 // This shuffle is custom lowered into a long sequence of:
482 // 2x vextractf128 , 4x vpshufb , 2x vpor , 1x vinsertf128
483 {ISD::VECTOR_SHUFFLE, MVT::v32i8, 9}
484 };
485
486 if (ST->hasAVX()) {
487 int Idx = CostTableLookup(AVXAltShuffleTbl, ISD::VECTOR_SHUFFLE, LT.second);
488 if (Idx != -1)
489 return LT.first * AVXAltShuffleTbl[Idx].Cost;
490 }
491
492 static const CostTblEntry<MVT::SimpleValueType> SSE41AltShuffleTbl[] = {
493 // These are lowered into movsd.
494 {ISD::VECTOR_SHUFFLE, MVT::v2i64, 1},
495 {ISD::VECTOR_SHUFFLE, MVT::v2f64, 1},
496
497 // packed float vectors with four elements are lowered into BLENDI dag
498 // nodes. A v4i32/v4f32 BLENDI generates a single 'blendps'/'blendpd'.
499 {ISD::VECTOR_SHUFFLE, MVT::v4i32, 1},
500 {ISD::VECTOR_SHUFFLE, MVT::v4f32, 1},
501
502 // This shuffle generates a single pshufw.
503 {ISD::VECTOR_SHUFFLE, MVT::v8i16, 1},
504
505 // There is no instruction that matches a v16i8 alternate shuffle.
506 // The backend will expand it into the sequence 'pshufb + pshufb + or'.
507 {ISD::VECTOR_SHUFFLE, MVT::v16i8, 3}
508 };
509
510 if (ST->hasSSE41()) {
511 int Idx = CostTableLookup(SSE41AltShuffleTbl, ISD::VECTOR_SHUFFLE, LT.second);
512 if (Idx != -1)
513 return LT.first * SSE41AltShuffleTbl[Idx].Cost;
514 }
515
516 static const CostTblEntry<MVT::SimpleValueType> SSSE3AltShuffleTbl[] = {
517 {ISD::VECTOR_SHUFFLE, MVT::v2i64, 1}, // movsd
518 {ISD::VECTOR_SHUFFLE, MVT::v2f64, 1}, // movsd
519
520 // SSE3 doesn't have 'blendps'. The following shuffles are expanded into
521 // the sequence 'shufps + pshufd'
522 {ISD::VECTOR_SHUFFLE, MVT::v4i32, 2},
523 {ISD::VECTOR_SHUFFLE, MVT::v4f32, 2},
524
525 {ISD::VECTOR_SHUFFLE, MVT::v8i16, 3}, // pshufb + pshufb + or
526 {ISD::VECTOR_SHUFFLE, MVT::v16i8, 3} // pshufb + pshufb + or
527 };
528
529 if (ST->hasSSSE3()) {
530 int Idx = CostTableLookup(SSSE3AltShuffleTbl, ISD::VECTOR_SHUFFLE, LT.second);
531 if (Idx != -1)
532 return LT.first * SSSE3AltShuffleTbl[Idx].Cost;
533 }
534
535 static const CostTblEntry<MVT::SimpleValueType> SSEAltShuffleTbl[] = {
536 {ISD::VECTOR_SHUFFLE, MVT::v2i64, 1}, // movsd
537 {ISD::VECTOR_SHUFFLE, MVT::v2f64, 1}, // movsd
538
539 {ISD::VECTOR_SHUFFLE, MVT::v4i32, 2}, // shufps + pshufd
540 {ISD::VECTOR_SHUFFLE, MVT::v4f32, 2}, // shufps + pshufd
541
542 // This is expanded into a long sequence of four extract + four insert.
543 {ISD::VECTOR_SHUFFLE, MVT::v8i16, 8}, // 4 x pextrw + 4 pinsrw.
544
545 // 8 x (pinsrw + pextrw + and + movb + movzb + or)
546 {ISD::VECTOR_SHUFFLE, MVT::v16i8, 48}
547 };
548
549 // Fall-back (SSE3 and SSE2).
550 int Idx = CostTableLookup(SSEAltShuffleTbl, ISD::VECTOR_SHUFFLE, LT.second);
551 if (Idx != -1)
552 return LT.first * SSEAltShuffleTbl[Idx].Cost;
553 return TargetTransformInfo::getShuffleCost(Kind, Tp, Index, SubTp);
Karthik Bhate03a25d2014-06-20 04:32:48 +0000554 }
555
556 return TargetTransformInfo::getShuffleCost(Kind, Tp, Index, SubTp);
Chandler Carruth664e3542013-01-07 01:37:14 +0000557}
558
559unsigned X86TTI::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src) const {
560 int ISD = TLI->InstructionOpcodeToISD(Opcode);
561 assert(ISD && "Invalid opcode");
562
Arnold Schwaighoferf47d2d72013-04-08 18:05:48 +0000563 std::pair<unsigned, MVT> LTSrc = TLI->getTypeLegalizationCost(Src);
564 std::pair<unsigned, MVT> LTDest = TLI->getTypeLegalizationCost(Dst);
565
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000566 static const TypeConversionCostTblEntry<MVT::SimpleValueType>
567 SSE2ConvTbl[] = {
Arnold Schwaighoferf47d2d72013-04-08 18:05:48 +0000568 // These are somewhat magic numbers justified by looking at the output of
569 // Intel's IACA, running some kernels and making sure when we take
570 // legalization into account the throughput will be overestimated.
571 { ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i64, 2*10 },
572 { ISD::UINT_TO_FP, MVT::v2f64, MVT::v4i32, 4*10 },
573 { ISD::UINT_TO_FP, MVT::v2f64, MVT::v8i16, 8*10 },
574 { ISD::UINT_TO_FP, MVT::v2f64, MVT::v16i8, 16*10 },
575 { ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i64, 2*10 },
576 { ISD::SINT_TO_FP, MVT::v2f64, MVT::v4i32, 4*10 },
577 { ISD::SINT_TO_FP, MVT::v2f64, MVT::v8i16, 8*10 },
578 { ISD::SINT_TO_FP, MVT::v2f64, MVT::v16i8, 16*10 },
579 // There are faster sequences for float conversions.
580 { ISD::UINT_TO_FP, MVT::v4f32, MVT::v2i64, 15 },
Quentin Colombet360460b2014-11-11 02:23:47 +0000581 { ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i32, 8 },
Arnold Schwaighoferf47d2d72013-04-08 18:05:48 +0000582 { ISD::UINT_TO_FP, MVT::v4f32, MVT::v8i16, 15 },
583 { ISD::UINT_TO_FP, MVT::v4f32, MVT::v16i8, 8 },
584 { ISD::SINT_TO_FP, MVT::v4f32, MVT::v2i64, 15 },
585 { ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i32, 15 },
586 { ISD::SINT_TO_FP, MVT::v4f32, MVT::v8i16, 15 },
587 { ISD::SINT_TO_FP, MVT::v4f32, MVT::v16i8, 8 },
588 };
589
590 if (ST->hasSSE2() && !ST->hasAVX()) {
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000591 int Idx =
592 ConvertCostTableLookup(SSE2ConvTbl, ISD, LTDest.second, LTSrc.second);
Arnold Schwaighoferf47d2d72013-04-08 18:05:48 +0000593 if (Idx != -1)
594 return LTSrc.first * SSE2ConvTbl[Idx].Cost;
595 }
596
Elena Demikhovsky27012472014-09-16 07:57:37 +0000597 static const TypeConversionCostTblEntry<MVT::SimpleValueType>
598 AVX512ConversionTbl[] = {
599 { ISD::FP_EXTEND, MVT::v8f64, MVT::v8f32, 1 },
600 { ISD::FP_EXTEND, MVT::v8f64, MVT::v16f32, 3 },
601 { ISD::FP_ROUND, MVT::v8f32, MVT::v8f64, 1 },
602 { ISD::FP_ROUND, MVT::v16f32, MVT::v8f64, 3 },
603
604 { ISD::TRUNCATE, MVT::v16i8, MVT::v16i32, 1 },
605 { ISD::TRUNCATE, MVT::v16i16, MVT::v16i32, 1 },
606 { ISD::TRUNCATE, MVT::v8i16, MVT::v8i64, 1 },
607 { ISD::TRUNCATE, MVT::v8i32, MVT::v8i64, 1 },
608 { ISD::TRUNCATE, MVT::v16i32, MVT::v8i64, 4 },
609
610 // v16i1 -> v16i32 - load + broadcast
611 { ISD::SIGN_EXTEND, MVT::v16i32, MVT::v16i1, 2 },
612 { ISD::ZERO_EXTEND, MVT::v16i32, MVT::v16i1, 2 },
613
614 { ISD::SIGN_EXTEND, MVT::v16i32, MVT::v16i8, 1 },
615 { ISD::ZERO_EXTEND, MVT::v16i32, MVT::v16i8, 1 },
616 { ISD::SIGN_EXTEND, MVT::v16i32, MVT::v16i16, 1 },
617 { ISD::ZERO_EXTEND, MVT::v16i32, MVT::v16i16, 1 },
618 { ISD::SIGN_EXTEND, MVT::v8i64, MVT::v16i32, 3 },
619 { ISD::ZERO_EXTEND, MVT::v8i64, MVT::v16i32, 3 },
620
621 };
622
623 if (ST->hasAVX512()) {
624 int Idx = ConvertCostTableLookup(AVX512ConversionTbl, ISD, LTDest.second,
625 LTSrc.second);
626 if (Idx != -1)
627 return AVX512ConversionTbl[Idx].Cost;
628 }
Chandler Carruth664e3542013-01-07 01:37:14 +0000629 EVT SrcTy = TLI->getValueType(Src);
630 EVT DstTy = TLI->getValueType(Dst);
631
Arnold Schwaighoferc0c7ff42013-04-17 20:04:53 +0000632 // The function getSimpleVT only handles simple value types.
633 if (!SrcTy.isSimple() || !DstTy.isSimple())
634 return TargetTransformInfo::getCastInstrCost(Opcode, Dst, Src);
635
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000636 static const TypeConversionCostTblEntry<MVT::SimpleValueType>
Tim Northoverf0e21612014-02-06 18:18:36 +0000637 AVX2ConversionTbl[] = {
638 { ISD::SIGN_EXTEND, MVT::v16i16, MVT::v16i8, 1 },
639 { ISD::ZERO_EXTEND, MVT::v16i16, MVT::v16i8, 1 },
640 { ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i1, 3 },
641 { ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i1, 3 },
642 { ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i8, 3 },
643 { ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i8, 3 },
644 { ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i16, 1 },
645 { ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i16, 1 },
646 { ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i1, 3 },
647 { ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i1, 3 },
648 { ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i8, 3 },
649 { ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i8, 3 },
650 { ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i16, 3 },
651 { ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i16, 3 },
652 { ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i32, 1 },
653 { ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i32, 1 },
654
655 { ISD::TRUNCATE, MVT::v4i8, MVT::v4i64, 2 },
656 { ISD::TRUNCATE, MVT::v4i16, MVT::v4i64, 2 },
657 { ISD::TRUNCATE, MVT::v4i32, MVT::v4i64, 2 },
658 { ISD::TRUNCATE, MVT::v8i8, MVT::v8i32, 2 },
659 { ISD::TRUNCATE, MVT::v8i16, MVT::v8i32, 2 },
660 { ISD::TRUNCATE, MVT::v8i32, MVT::v8i64, 4 },
Elena Demikhovsky27012472014-09-16 07:57:37 +0000661
662 { ISD::FP_EXTEND, MVT::v8f64, MVT::v8f32, 3 },
663 { ISD::FP_ROUND, MVT::v8f32, MVT::v8f64, 3 },
Quentin Colombet360460b2014-11-11 02:23:47 +0000664
665 { ISD::UINT_TO_FP, MVT::v8f32, MVT::v8i32, 8 },
Tim Northoverf0e21612014-02-06 18:18:36 +0000666 };
667
668 static const TypeConversionCostTblEntry<MVT::SimpleValueType>
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000669 AVXConversionTbl[] = {
Tim Northoverf0e21612014-02-06 18:18:36 +0000670 { ISD::SIGN_EXTEND, MVT::v16i16, MVT::v16i8, 4 },
671 { ISD::ZERO_EXTEND, MVT::v16i16, MVT::v16i8, 4 },
672 { ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i1, 7 },
673 { ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i1, 4 },
674 { ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i8, 7 },
675 { ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i8, 4 },
676 { ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i16, 4 },
677 { ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i16, 4 },
678 { ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i1, 6 },
679 { ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i1, 4 },
680 { ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i8, 6 },
681 { ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i8, 4 },
682 { ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i16, 6 },
683 { ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i16, 3 },
684 { ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i32, 4 },
685 { ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i32, 4 },
686
687 { ISD::TRUNCATE, MVT::v4i8, MVT::v4i64, 4 },
688 { ISD::TRUNCATE, MVT::v4i16, MVT::v4i64, 4 },
689 { ISD::TRUNCATE, MVT::v4i32, MVT::v4i64, 4 },
690 { ISD::TRUNCATE, MVT::v8i8, MVT::v8i32, 4 },
691 { ISD::TRUNCATE, MVT::v8i16, MVT::v8i32, 5 },
692 { ISD::TRUNCATE, MVT::v16i8, MVT::v16i16, 4 },
693 { ISD::TRUNCATE, MVT::v8i32, MVT::v8i64, 9 },
Benjamin Kramer52ceb442013-04-01 10:23:49 +0000694
695 { ISD::SINT_TO_FP, MVT::v8f32, MVT::v8i1, 8 },
696 { ISD::SINT_TO_FP, MVT::v8f32, MVT::v8i8, 8 },
697 { ISD::SINT_TO_FP, MVT::v8f32, MVT::v8i16, 5 },
698 { ISD::SINT_TO_FP, MVT::v8f32, MVT::v8i32, 1 },
699 { ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i1, 3 },
700 { ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i8, 3 },
701 { ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i16, 3 },
702 { ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i32, 1 },
703 { ISD::SINT_TO_FP, MVT::v4f64, MVT::v4i1, 3 },
704 { ISD::SINT_TO_FP, MVT::v4f64, MVT::v4i8, 3 },
705 { ISD::SINT_TO_FP, MVT::v4f64, MVT::v4i16, 3 },
706 { ISD::SINT_TO_FP, MVT::v4f64, MVT::v4i32, 1 },
707
708 { ISD::UINT_TO_FP, MVT::v8f32, MVT::v8i1, 6 },
709 { ISD::UINT_TO_FP, MVT::v8f32, MVT::v8i8, 5 },
710 { ISD::UINT_TO_FP, MVT::v8f32, MVT::v8i16, 5 },
711 { ISD::UINT_TO_FP, MVT::v8f32, MVT::v8i32, 9 },
712 { ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i1, 7 },
713 { ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i8, 2 },
714 { ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i16, 2 },
715 { ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i32, 6 },
716 { ISD::UINT_TO_FP, MVT::v4f64, MVT::v4i1, 7 },
717 { ISD::UINT_TO_FP, MVT::v4f64, MVT::v4i8, 2 },
718 { ISD::UINT_TO_FP, MVT::v4f64, MVT::v4i16, 2 },
719 { ISD::UINT_TO_FP, MVT::v4f64, MVT::v4i32, 6 },
Quentin Colombet85b904d2014-03-27 22:27:41 +0000720 // The generic code to compute the scalar overhead is currently broken.
721 // Workaround this limitation by estimating the scalarization overhead
722 // here. We have roughly 10 instructions per scalar element.
723 // Multiply that by the vector width.
724 // FIXME: remove that when PR19268 is fixed.
Quentin Colombet3914bf52014-03-27 00:52:16 +0000725 { ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i64, 2*10 },
726 { ISD::UINT_TO_FP, MVT::v4f64, MVT::v4i64, 4*10 },
Benjamin Kramer52ceb442013-04-01 10:23:49 +0000727
Jim Grosbach72fbde82014-03-27 00:04:11 +0000728 { ISD::FP_TO_SINT, MVT::v8i8, MVT::v8f32, 7 },
Renato Goline1fb0592013-01-20 20:57:20 +0000729 { ISD::FP_TO_SINT, MVT::v4i8, MVT::v4f32, 1 },
Adam Nemet6dafe972014-03-30 18:07:13 +0000730 // This node is expanded into scalarized operations but BasicTTI is overly
731 // optimistic estimating its cost. It computes 3 per element (one
732 // vector-extract, one scalar conversion and one vector-insert). The
733 // problem is that the inserts form a read-modify-write chain so latency
734 // should be factored in too. Inflating the cost per element by 1.
735 { ISD::FP_TO_UINT, MVT::v8i32, MVT::v8f32, 8*4 },
Adam Nemet10c4ce22014-03-31 21:54:48 +0000736 { ISD::FP_TO_UINT, MVT::v4i32, MVT::v4f64, 4*4 },
Chandler Carruth664e3542013-01-07 01:37:14 +0000737 };
738
Tim Northoverf0e21612014-02-06 18:18:36 +0000739 if (ST->hasAVX2()) {
740 int Idx = ConvertCostTableLookup(AVX2ConversionTbl, ISD,
741 DstTy.getSimpleVT(), SrcTy.getSimpleVT());
742 if (Idx != -1)
743 return AVX2ConversionTbl[Idx].Cost;
744 }
745
Chandler Carruth664e3542013-01-07 01:37:14 +0000746 if (ST->hasAVX()) {
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000747 int Idx = ConvertCostTableLookup(AVXConversionTbl, ISD, DstTy.getSimpleVT(),
748 SrcTy.getSimpleVT());
Renato Goline1fb0592013-01-20 20:57:20 +0000749 if (Idx != -1)
750 return AVXConversionTbl[Idx].Cost;
Chandler Carruth664e3542013-01-07 01:37:14 +0000751 }
752
753 return TargetTransformInfo::getCastInstrCost(Opcode, Dst, Src);
754}
755
756unsigned X86TTI::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
757 Type *CondTy) const {
758 // Legalize the type.
759 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(ValTy);
760
761 MVT MTy = LT.second;
762
763 int ISD = TLI->InstructionOpcodeToISD(Opcode);
764 assert(ISD && "Invalid opcode");
765
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000766 static const CostTblEntry<MVT::SimpleValueType> SSE42CostTbl[] = {
Renato Goline1fb0592013-01-20 20:57:20 +0000767 { ISD::SETCC, MVT::v2f64, 1 },
768 { ISD::SETCC, MVT::v4f32, 1 },
769 { ISD::SETCC, MVT::v2i64, 1 },
770 { ISD::SETCC, MVT::v4i32, 1 },
771 { ISD::SETCC, MVT::v8i16, 1 },
772 { ISD::SETCC, MVT::v16i8, 1 },
Chandler Carruth664e3542013-01-07 01:37:14 +0000773 };
774
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000775 static const CostTblEntry<MVT::SimpleValueType> AVX1CostTbl[] = {
Renato Goline1fb0592013-01-20 20:57:20 +0000776 { ISD::SETCC, MVT::v4f64, 1 },
777 { ISD::SETCC, MVT::v8f32, 1 },
Chandler Carruth664e3542013-01-07 01:37:14 +0000778 // AVX1 does not support 8-wide integer compare.
Renato Goline1fb0592013-01-20 20:57:20 +0000779 { ISD::SETCC, MVT::v4i64, 4 },
780 { ISD::SETCC, MVT::v8i32, 4 },
781 { ISD::SETCC, MVT::v16i16, 4 },
782 { ISD::SETCC, MVT::v32i8, 4 },
Chandler Carruth664e3542013-01-07 01:37:14 +0000783 };
784
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000785 static const CostTblEntry<MVT::SimpleValueType> AVX2CostTbl[] = {
Renato Goline1fb0592013-01-20 20:57:20 +0000786 { ISD::SETCC, MVT::v4i64, 1 },
787 { ISD::SETCC, MVT::v8i32, 1 },
788 { ISD::SETCC, MVT::v16i16, 1 },
789 { ISD::SETCC, MVT::v32i8, 1 },
Chandler Carruth664e3542013-01-07 01:37:14 +0000790 };
791
Elena Demikhovsky27012472014-09-16 07:57:37 +0000792 static const CostTblEntry<MVT::SimpleValueType> AVX512CostTbl[] = {
793 { ISD::SETCC, MVT::v8i64, 1 },
794 { ISD::SETCC, MVT::v16i32, 1 },
795 { ISD::SETCC, MVT::v8f64, 1 },
796 { ISD::SETCC, MVT::v16f32, 1 },
797 };
798
799 if (ST->hasAVX512()) {
800 int Idx = CostTableLookup(AVX512CostTbl, ISD, MTy);
801 if (Idx != -1)
802 return LT.first * AVX512CostTbl[Idx].Cost;
803 }
804
Chandler Carruth664e3542013-01-07 01:37:14 +0000805 if (ST->hasAVX2()) {
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000806 int Idx = CostTableLookup(AVX2CostTbl, ISD, MTy);
Renato Goline1fb0592013-01-20 20:57:20 +0000807 if (Idx != -1)
808 return LT.first * AVX2CostTbl[Idx].Cost;
Chandler Carruth664e3542013-01-07 01:37:14 +0000809 }
810
811 if (ST->hasAVX()) {
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000812 int Idx = CostTableLookup(AVX1CostTbl, ISD, MTy);
Renato Goline1fb0592013-01-20 20:57:20 +0000813 if (Idx != -1)
814 return LT.first * AVX1CostTbl[Idx].Cost;
Chandler Carruth664e3542013-01-07 01:37:14 +0000815 }
816
817 if (ST->hasSSE42()) {
Benjamin Kramer21585fd2013-08-09 19:33:32 +0000818 int Idx = CostTableLookup(SSE42CostTbl, ISD, MTy);
Renato Goline1fb0592013-01-20 20:57:20 +0000819 if (Idx != -1)
820 return LT.first * SSE42CostTbl[Idx].Cost;
Chandler Carruth664e3542013-01-07 01:37:14 +0000821 }
822
823 return TargetTransformInfo::getCmpSelInstrCost(Opcode, ValTy, CondTy);
824}
825
826unsigned X86TTI::getVectorInstrCost(unsigned Opcode, Type *Val,
827 unsigned Index) const {
828 assert(Val->isVectorTy() && "This must be a vector type");
829
830 if (Index != -1U) {
831 // Legalize the type.
832 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Val);
833
834 // This type is legalized to a scalar type.
835 if (!LT.second.isVector())
836 return 0;
837
838 // The type may be split. Normalize the index to the new type.
839 unsigned Width = LT.second.getVectorNumElements();
840 Index = Index % Width;
841
842 // Floating point scalars are already located in index #0.
843 if (Val->getScalarType()->isFloatingPointTy() && Index == 0)
844 return 0;
845 }
846
847 return TargetTransformInfo::getVectorInstrCost(Opcode, Val, Index);
848}
849
Nadav Rotemf9ecbcb2013-06-27 17:52:04 +0000850unsigned X86TTI::getScalarizationOverhead(Type *Ty, bool Insert,
851 bool Extract) const {
852 assert (Ty->isVectorTy() && "Can only scalarize vectors");
853 unsigned Cost = 0;
854
855 for (int i = 0, e = Ty->getVectorNumElements(); i < e; ++i) {
856 if (Insert)
857 Cost += TopTTI->getVectorInstrCost(Instruction::InsertElement, Ty, i);
858 if (Extract)
859 Cost += TopTTI->getVectorInstrCost(Instruction::ExtractElement, Ty, i);
860 }
861
862 return Cost;
863}
864
Chandler Carruth664e3542013-01-07 01:37:14 +0000865unsigned X86TTI::getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
866 unsigned AddressSpace) const {
Alp Tokerf907b892013-12-05 05:44:44 +0000867 // Handle non-power-of-two vectors such as <3 x float>
Nadav Rotemf9ecbcb2013-06-27 17:52:04 +0000868 if (VectorType *VTy = dyn_cast<VectorType>(Src)) {
869 unsigned NumElem = VTy->getVectorNumElements();
870
871 // Handle a few common cases:
872 // <3 x float>
873 if (NumElem == 3 && VTy->getScalarSizeInBits() == 32)
874 // Cost = 64 bit store + extract + 32 bit store.
875 return 3;
876
877 // <3 x double>
878 if (NumElem == 3 && VTy->getScalarSizeInBits() == 64)
879 // Cost = 128 bit store + unpack + 64 bit store.
880 return 3;
881
Alp Tokerf907b892013-12-05 05:44:44 +0000882 // Assume that all other non-power-of-two numbers are scalarized.
Nadav Rotemf9ecbcb2013-06-27 17:52:04 +0000883 if (!isPowerOf2_32(NumElem)) {
884 unsigned Cost = TargetTransformInfo::getMemoryOpCost(Opcode,
885 VTy->getScalarType(),
886 Alignment,
887 AddressSpace);
888 unsigned SplitCost = getScalarizationOverhead(Src,
889 Opcode == Instruction::Load,
890 Opcode==Instruction::Store);
891 return NumElem * Cost + SplitCost;
892 }
893 }
894
Chandler Carruth664e3542013-01-07 01:37:14 +0000895 // Legalize the type.
896 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Src);
897 assert((Opcode == Instruction::Load || Opcode == Instruction::Store) &&
898 "Invalid Opcode");
899
900 // Each load/store unit costs 1.
901 unsigned Cost = LT.first * 1;
902
903 // On Sandybridge 256bit load/stores are double pumped
904 // (but not on Haswell).
905 if (LT.second.getSizeInBits() > 128 && !ST->hasAVX2())
906 Cost*=2;
907
908 return Cost;
909}
Arnold Schwaighofer6042a262013-07-12 19:16:07 +0000910
911unsigned X86TTI::getAddressComputationCost(Type *Ty, bool IsComplex) const {
912 // Address computations in vectorized code with non-consecutive addresses will
913 // likely result in more instructions compared to scalar code where the
914 // computation can more often be merged into the index mode. The resulting
915 // extra micro-ops can significantly decrease throughput.
916 unsigned NumVectorInstToHideOverhead = 10;
917
918 if (Ty->isVectorTy() && IsComplex)
919 return NumVectorInstToHideOverhead;
920
921 return TargetTransformInfo::getAddressComputationCost(Ty, IsComplex);
922}
Yi Jiang5c343de2013-09-19 17:48:48 +0000923
924unsigned X86TTI::getReductionCost(unsigned Opcode, Type *ValTy,
925 bool IsPairwise) const {
926
927 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(ValTy);
928
929 MVT MTy = LT.second;
930
931 int ISD = TLI->InstructionOpcodeToISD(Opcode);
932 assert(ISD && "Invalid opcode");
933
934 // We use the Intel Architecture Code Analyzer(IACA) to measure the throughput
935 // and make it as the cost.
936
937 static const CostTblEntry<MVT::SimpleValueType> SSE42CostTblPairWise[] = {
938 { ISD::FADD, MVT::v2f64, 2 },
939 { ISD::FADD, MVT::v4f32, 4 },
940 { ISD::ADD, MVT::v2i64, 2 }, // The data reported by the IACA tool is "1.6".
941 { ISD::ADD, MVT::v4i32, 3 }, // The data reported by the IACA tool is "3.5".
942 { ISD::ADD, MVT::v8i16, 5 },
943 };
944
945 static const CostTblEntry<MVT::SimpleValueType> AVX1CostTblPairWise[] = {
946 { ISD::FADD, MVT::v4f32, 4 },
947 { ISD::FADD, MVT::v4f64, 5 },
948 { ISD::FADD, MVT::v8f32, 7 },
949 { ISD::ADD, MVT::v2i64, 1 }, // The data reported by the IACA tool is "1.5".
950 { ISD::ADD, MVT::v4i32, 3 }, // The data reported by the IACA tool is "3.5".
951 { ISD::ADD, MVT::v4i64, 5 }, // The data reported by the IACA tool is "4.8".
952 { ISD::ADD, MVT::v8i16, 5 },
953 { ISD::ADD, MVT::v8i32, 5 },
954 };
955
956 static const CostTblEntry<MVT::SimpleValueType> SSE42CostTblNoPairWise[] = {
957 { ISD::FADD, MVT::v2f64, 2 },
958 { ISD::FADD, MVT::v4f32, 4 },
959 { ISD::ADD, MVT::v2i64, 2 }, // The data reported by the IACA tool is "1.6".
960 { ISD::ADD, MVT::v4i32, 3 }, // The data reported by the IACA tool is "3.3".
961 { ISD::ADD, MVT::v8i16, 4 }, // The data reported by the IACA tool is "4.3".
962 };
963
964 static const CostTblEntry<MVT::SimpleValueType> AVX1CostTblNoPairWise[] = {
965 { ISD::FADD, MVT::v4f32, 3 },
966 { ISD::FADD, MVT::v4f64, 3 },
967 { ISD::FADD, MVT::v8f32, 4 },
968 { ISD::ADD, MVT::v2i64, 1 }, // The data reported by the IACA tool is "1.5".
969 { ISD::ADD, MVT::v4i32, 3 }, // The data reported by the IACA tool is "2.8".
970 { ISD::ADD, MVT::v4i64, 3 },
971 { ISD::ADD, MVT::v8i16, 4 },
972 { ISD::ADD, MVT::v8i32, 5 },
973 };
974
975 if (IsPairwise) {
976 if (ST->hasAVX()) {
977 int Idx = CostTableLookup(AVX1CostTblPairWise, ISD, MTy);
978 if (Idx != -1)
979 return LT.first * AVX1CostTblPairWise[Idx].Cost;
980 }
981
982 if (ST->hasSSE42()) {
983 int Idx = CostTableLookup(SSE42CostTblPairWise, ISD, MTy);
984 if (Idx != -1)
985 return LT.first * SSE42CostTblPairWise[Idx].Cost;
986 }
987 } else {
988 if (ST->hasAVX()) {
989 int Idx = CostTableLookup(AVX1CostTblNoPairWise, ISD, MTy);
990 if (Idx != -1)
991 return LT.first * AVX1CostTblNoPairWise[Idx].Cost;
992 }
993
994 if (ST->hasSSE42()) {
995 int Idx = CostTableLookup(SSE42CostTblNoPairWise, ISD, MTy);
996 if (Idx != -1)
997 return LT.first * SSE42CostTblNoPairWise[Idx].Cost;
998 }
999 }
1000
1001 return TargetTransformInfo::getReductionCost(Opcode, ValTy, IsPairwise);
1002}
1003
Juergen Ributzkab2e4edb2014-06-10 00:32:29 +00001004/// \brief Calculate the cost of materializing a 64-bit value. This helper
1005/// method might only calculate a fraction of a larger immediate. Therefore it
1006/// is valid to return a cost of ZERO.
1007unsigned X86TTI::getIntImmCost(int64_t Val) const {
1008 if (Val == 0)
1009 return TCC_Free;
1010
1011 if (isInt<32>(Val))
1012 return TCC_Basic;
1013
1014 return 2 * TCC_Basic;
1015}
1016
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001017unsigned X86TTI::getIntImmCost(const APInt &Imm, Type *Ty) const {
1018 assert(Ty->isIntegerTy());
1019
1020 unsigned BitSize = Ty->getPrimitiveSizeInBits();
1021 if (BitSize == 0)
1022 return ~0U;
1023
Juergen Ributzka43176172014-05-19 21:00:53 +00001024 // Never hoist constants larger than 128bit, because this might lead to
1025 // incorrect code generation or assertions in codegen.
1026 // Fixme: Create a cost model for types larger than i128 once the codegen
1027 // issues have been fixed.
1028 if (BitSize > 128)
1029 return TCC_Free;
1030
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001031 if (Imm == 0)
1032 return TCC_Free;
1033
Juergen Ributzkab2e4edb2014-06-10 00:32:29 +00001034 // Sign-extend all constants to a multiple of 64-bit.
1035 APInt ImmVal = Imm;
1036 if (BitSize & 0x3f)
1037 ImmVal = Imm.sext((BitSize + 63) & ~0x3fU);
1038
1039 // Split the constant into 64-bit chunks and calculate the cost for each
1040 // chunk.
1041 unsigned Cost = 0;
1042 for (unsigned ShiftVal = 0; ShiftVal < BitSize; ShiftVal += 64) {
1043 APInt Tmp = ImmVal.ashr(ShiftVal).sextOrTrunc(64);
1044 int64_t Val = Tmp.getSExtValue();
1045 Cost += getIntImmCost(Val);
1046 }
1047 // We need at least one instruction to materialze the constant.
1048 return std::max(1U, Cost);
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001049}
1050
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001051unsigned X86TTI::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001052 Type *Ty) const {
1053 assert(Ty->isIntegerTy());
1054
1055 unsigned BitSize = Ty->getPrimitiveSizeInBits();
Juergen Ributzka43176172014-05-19 21:00:53 +00001056 // There is no cost model for constants with a bit size of 0. Return TCC_Free
1057 // here, so that constant hoisting will ignore this constant.
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001058 if (BitSize == 0)
Juergen Ributzka43176172014-05-19 21:00:53 +00001059 return TCC_Free;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001060
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001061 unsigned ImmIdx = ~0U;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001062 switch (Opcode) {
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001063 default: return TCC_Free;
1064 case Instruction::GetElementPtr:
Juergen Ributzka27435b32014-04-02 21:45:36 +00001065 // Always hoist the base address of a GetElementPtr. This prevents the
1066 // creation of new constants for every base constant that gets constant
1067 // folded with the offset.
Juergen Ributzka631c4912014-03-25 18:01:25 +00001068 if (Idx == 0)
1069 return 2 * TCC_Basic;
1070 return TCC_Free;
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001071 case Instruction::Store:
1072 ImmIdx = 0;
1073 break;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001074 case Instruction::Add:
1075 case Instruction::Sub:
1076 case Instruction::Mul:
1077 case Instruction::UDiv:
1078 case Instruction::SDiv:
1079 case Instruction::URem:
1080 case Instruction::SRem:
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001081 case Instruction::And:
1082 case Instruction::Or:
1083 case Instruction::Xor:
1084 case Instruction::ICmp:
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001085 ImmIdx = 1;
1086 break;
Michael Zolotukhin1f4a9602014-04-30 19:17:32 +00001087 // Always return TCC_Free for the shift value of a shift instruction.
1088 case Instruction::Shl:
1089 case Instruction::LShr:
1090 case Instruction::AShr:
1091 if (Idx == 1)
1092 return TCC_Free;
1093 break;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001094 case Instruction::Trunc:
1095 case Instruction::ZExt:
1096 case Instruction::SExt:
1097 case Instruction::IntToPtr:
1098 case Instruction::PtrToInt:
1099 case Instruction::BitCast:
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001100 case Instruction::PHI:
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001101 case Instruction::Call:
1102 case Instruction::Select:
1103 case Instruction::Ret:
1104 case Instruction::Load:
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001105 break;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001106 }
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001107
Juergen Ributzkab2e4edb2014-06-10 00:32:29 +00001108 if (Idx == ImmIdx) {
1109 unsigned NumConstants = (BitSize + 63) / 64;
1110 unsigned Cost = X86TTI::getIntImmCost(Imm, Ty);
Saleem Abdulrasool3c890c42014-06-12 17:56:18 +00001111 return (Cost <= NumConstants * TCC_Basic)
1112 ? static_cast<unsigned>(TCC_Free)
1113 : Cost;
Juergen Ributzkab2e4edb2014-06-10 00:32:29 +00001114 }
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001115
1116 return X86TTI::getIntImmCost(Imm, Ty);
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001117}
1118
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001119unsigned X86TTI::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
1120 const APInt &Imm, Type *Ty) const {
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001121 assert(Ty->isIntegerTy());
1122
1123 unsigned BitSize = Ty->getPrimitiveSizeInBits();
Juergen Ributzka43176172014-05-19 21:00:53 +00001124 // There is no cost model for constants with a bit size of 0. Return TCC_Free
1125 // here, so that constant hoisting will ignore this constant.
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001126 if (BitSize == 0)
Juergen Ributzka43176172014-05-19 21:00:53 +00001127 return TCC_Free;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001128
1129 switch (IID) {
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001130 default: return TCC_Free;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001131 case Intrinsic::sadd_with_overflow:
1132 case Intrinsic::uadd_with_overflow:
1133 case Intrinsic::ssub_with_overflow:
1134 case Intrinsic::usub_with_overflow:
1135 case Intrinsic::smul_with_overflow:
1136 case Intrinsic::umul_with_overflow:
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001137 if ((Idx == 1) && Imm.getBitWidth() <= 64 && isInt<32>(Imm.getSExtValue()))
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001138 return TCC_Free;
Juergen Ributzka5eef98c2014-03-25 18:01:23 +00001139 break;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001140 case Intrinsic::experimental_stackmap:
Juergen Ributzka5eef98c2014-03-25 18:01:23 +00001141 if ((Idx < 2) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue())))
Juergen Ributzkaf0dff492014-03-21 06:04:45 +00001142 return TCC_Free;
Juergen Ributzka5eef98c2014-03-25 18:01:23 +00001143 break;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001144 case Intrinsic::experimental_patchpoint_void:
1145 case Intrinsic::experimental_patchpoint_i64:
Juergen Ributzka5eef98c2014-03-25 18:01:23 +00001146 if ((Idx < 4) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue())))
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001147 return TCC_Free;
Juergen Ributzka5eef98c2014-03-25 18:01:23 +00001148 break;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001149 }
Juergen Ributzka5eef98c2014-03-25 18:01:23 +00001150 return X86TTI::getIntImmCost(Imm, Ty);
Juergen Ributzkaf26beda2014-01-25 02:02:55 +00001151}