CostModel: We have API for checking the costs of known shuffles. This patch adds
authorNadav Rotem <nrotem@apple.com>
Mon, 24 Dec 2012 10:04:03 +0000 (10:04 +0000)
committerNadav Rotem <nrotem@apple.com>
Mon, 24 Dec 2012 10:04:03 +0000 (10:04 +0000)
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

include/llvm/Target/TargetTransformImpl.h
include/llvm/TargetTransformInfo.h
lib/Target/TargetTransformImpl.cpp

index f2229748be5ec27696e94f4ec80a3778f0ad4cc1..3b6ed1abd3d9b5cc46367fda7a18e79238f2b5a9 100644 (file)
@@ -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;
index 1a5dda3bb2836aa71e48d9dbfbefea526ae5bdfa..c97c7e4b0d790bbbafec7cf3de89058de4d3edf1 100644 (file)
@@ -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;
   }
 
index a320e16c98fae230d32b2370a3ac2031d73e62bc..235a8fc76a646f50d09fc8e995c1cbd73d932468 100644 (file)
@@ -209,7 +209,8 @@ unsigned VectorTargetTransformImpl::getArithmeticInstrCost(unsigned Opcode,
 }
 
 unsigned VectorTargetTransformImpl::getShuffleCost(ShuffleKind Kind,
-                                                   Type *Tp) const {
+                                                   Type *Tp,
+                                                   int Index) const {
   return 1;
 }