[llvm] [VectorCombine] Add free concats to shuffleToIdentity. (PR #94954)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 08:16:25 PDT 2024


================
@@ -1703,23 +1703,73 @@ generateInstLaneVectorFromOperand(ArrayRef<InstLane> Item, int Op) {
   return NItem;
 }
 
+/// Detect concat of multiple values into a vector
+static bool isFreeConcat(ArrayRef<InstLane> Item,
+                         const TargetTransformInfo &TTI) {
+  auto *Ty = cast<FixedVectorType>(Item.front().first->get()->getType());
+  unsigned NumElts = Ty->getNumElements();
+  if (Item.size() == NumElts || NumElts == 1 || Item.size() % NumElts != 0)
+    return false;
+
+  // Check that the concat is free, usually meaning that the type will be split
+  // during legalization.
+  SmallVector<int, 16> ConcatMask(Ty->getNumElements() * 2);
----------------
RKSimon wrote:

`NumElts * 2` - but why hardcode to 2?

https://github.com/llvm/llvm-project/pull/94954


More information about the llvm-commits mailing list