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"
20#include "llvm/Analysis/TargetTransformInfo.h"
21#include "llvm/Support/InstructionCost.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.
36InstructionCost
37getShuffleCost(const TargetTransformInfo &TTI,
38 TargetTransformInfo::ShuffleKind Kind, VectorType *Tp,
39 const TargetTransformInfo::TargetCostKind CostKind,
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,
47 const TargetTransformInfo::TargetCostKind CostKind, Type *ScalarTy,
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.
54InstructionCost
55getBlendedLoadCost(const TargetTransformInfo &TTI, Type *VecTy, Align Alignment,
56 unsigned AddressSpace,
57 const TargetTransformInfo::TargetCostKind CostKind);
58
59} // namespace llvm::slpvectorizer
60
61#endif // LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPCOSTANALYSIS_H
62