From: Nadav Rotem Date: Mon, 24 Dec 2012 10:04:03 +0000 (+0000) Subject: CostModel: We have API for checking the costs of known shuffles. This patch adds X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1e1c5f37c3a9b27c71d7d3a9e22f819200fb38b4;p=oota-llvm.git CostModel: We have API for checking the costs of known shuffles. This patch adds support for the insert-subvector and extract-subvector kinds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171027 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Target/TargetTransformImpl.h b/include/llvm/Target/TargetTransformImpl.h index f2229748be5..3b6ed1abd3d 100644 --- a/include/llvm/Target/TargetTransformImpl.h +++ b/include/llvm/Target/TargetTransformImpl.h @@ -71,7 +71,8 @@ public: 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/include/llvm/TargetTransformInfo.h b/include/llvm/TargetTransformInfo.h index 1a5dda3bb28..c97c7e4b0d7 100644 --- a/include/llvm/TargetTransformInfo.h +++ b/include/llvm/TargetTransformInfo.h @@ -158,8 +158,10 @@ public: 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 @@ public: } /// 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/lib/Target/TargetTransformImpl.cpp b/lib/Target/TargetTransformImpl.cpp index a320e16c98f..235a8fc76a6 100644 --- a/lib/Target/TargetTransformImpl.cpp +++ b/lib/Target/TargetTransformImpl.cpp @@ -209,7 +209,8 @@ unsigned VectorTargetTransformImpl::getArithmeticInstrCost(unsigned Opcode, } unsigned VectorTargetTransformImpl::getShuffleCost(ShuffleKind Kind, - Type *Tp) const { + Type *Tp, + int Index) const { return 1; }