CostModel: We have API for checking the costs of known shuffles. This patch adds
support for the insert-subvector and extract-subvector kinds.
llvm-svn: 171027
diff --git a/llvm/include/llvm/Target/TargetTransformImpl.h b/llvm/include/llvm/Target/TargetTransformImpl.h
index f222974..3b6ed1a 100644
--- a/llvm/include/llvm/Target/TargetTransformImpl.h
+++ b/llvm/include/llvm/Target/TargetTransformImpl.h
@@ -71,7 +71,8 @@
virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const;
- virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp) const;
+ virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp,
+ int Index) const;
virtual unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
Type *Src) const;
diff --git a/llvm/include/llvm/TargetTransformInfo.h b/llvm/include/llvm/TargetTransformInfo.h
index 1a5dda3..c97c7e4 100644
--- a/llvm/include/llvm/TargetTransformInfo.h
+++ b/llvm/include/llvm/TargetTransformInfo.h
@@ -158,8 +158,10 @@
virtual ~VectorTargetTransformInfo() {}
enum ShuffleKind {
- Broadcast, // Broadcast element 0 to all other elements.
- Reverse // Reverse the order of the vector.
+ Broadcast, // Broadcast element 0 to all other elements.
+ Reverse, // Reverse the order of the vector.
+ InsertSubvector, // InsertSubvector. Index indicates start offset.
+ ExtractSubvector // ExtractSubvector Index indicates start offset.
};
/// Returns the expected cost of arithmetic ops, such as mul, xor, fsub, etc.
@@ -168,7 +170,10 @@
}
/// Returns the cost of a shuffle instruction of kind Kind and of type Tp.
- virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp) const {
+ /// The index parameter is used by some of the shuffle kinds to add
+ /// additional information.
+ virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp,
+ int Index) const {
return 1;
}
diff --git a/llvm/lib/Target/TargetTransformImpl.cpp b/llvm/lib/Target/TargetTransformImpl.cpp
index a320e16..235a8fc 100644
--- a/llvm/lib/Target/TargetTransformImpl.cpp
+++ b/llvm/lib/Target/TargetTransformImpl.cpp
@@ -209,7 +209,8 @@
}
unsigned VectorTargetTransformImpl::getShuffleCost(ShuffleKind Kind,
- Type *Tp) const {
+ Type *Tp,
+ int Index) const {
return 1;
}