LLVM 24.0.0git
SLPCostAnalysis.h
Go to the documentation of this file.
1//===- SLPCostAnalysis.h - SLP Vectorizer free cost helpers ----*- C++ -*-===//
2//
3// 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
6//
7//===----------------------------------------------------------------------===//
8//
9// Internal header used by SLPVectorizer.cpp. It declares free cost helpers
10// that do not depend on BoUpSLP or any other SLP-private type. The bulk of
11// the SLP cost model still lives in SLPVectorizer.cpp because it references
12// BoUpSLP internals.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPCOSTANALYSIS_H
17#define LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPCOSTANALYSIS_H
18
19#include "llvm/ADT/ArrayRef.h"
22
23#include <utility>
24
25namespace llvm {
26class Type;
27class Value;
28class VectorType;
29} // namespace llvm
30
31namespace llvm::slpvectorizer {
32
33/// Returns the cost of the shuffle instructions with the given \p Kind, vector
34/// type \p Tp and optional \p Mask. Adds SLP-specific cost estimation for
35/// insert subvector pattern.
37getShuffleCost(const TargetTransformInfo &TTI,
38 TargetTransformInfo::ShuffleKind Kind, VectorType *Tp,
40 ArrayRef<int> Mask = {}, int Index = 0,
41 VectorType *SubTp = nullptr, ArrayRef<const Value *> Args = {});
42
43/// Calculate the scalar and the vector costs from vectorizing set of GEPs.
44std::pair<InstructionCost, InstructionCost>
45getGEPCosts(const TargetTransformInfo &TTI, ArrayRef<Value *> Ptrs,
46 Value *BasePtr, unsigned Opcode,
48 VectorType *VecTy);
49
50/// Returns the cost of a BlendedLoadVectorize node loading \p VecTy: two masked
51/// loads (one per candidate base), a xor to negate the false-lane mask and a
52/// select. The blend mask is a separate operand node, so its cost is counted
53/// there, not here.
55getBlendedLoadCost(const TargetTransformInfo &TTI, Type *VecTy, Align Alignment,
56 unsigned AddressSpace,
58
59} // namespace llvm::slpvectorizer
60
61#endif // LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPCOSTANALYSIS_H
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
This pass exposes codegen information to IR-level passes.
TargetCostKind
The kind of cost model.
ShuffleKind
The various kinds of shuffle patterns for vector queries.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
Base class of all SIMD vector types.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
A private "module" namespace for types and utilities used by this pass.
std::pair< InstructionCost, InstructionCost > getGEPCosts(const TargetTransformInfo &TTI, ArrayRef< Value * > Ptrs, Value *BasePtr, unsigned Opcode, const TTI::TargetCostKind CostKind, Type *ScalarTy, VectorType *VecTy)
Calculate the scalar and the vector costs from vectorizing set of GEPs.
InstructionCost getShuffleCost(const TargetTransformInfo &TTI, TTI::ShuffleKind Kind, VectorType *Tp, const TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args)
Returns the cost of the shuffle instructions with the given Kind, vector type Tp and optional Mask.
InstructionCost getBlendedLoadCost(const TargetTransformInfo &TTI, Type *VecTy, Align Alignment, unsigned AddressSpace, const TTI::TargetCostKind CostKind)
Returns the cost of a BlendedLoadVectorize node loading VecTy: two masked loads (one per candidate ba...
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
TargetTransformInfo TTI
ArrayRef(const T &OneElt) -> ArrayRef< T >