[llvm] [VectorCombine] Add free concats to shuffleToIdentity. (PR #94954)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 08:21:19 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);
----------------
davemgreen wrote:
The shuffle costs are limited to 2 inputs, so it is measuring the cost of the first step in the tree it needs to create, and assuming that if that is free the whole thing will be free. Does that sound OK or do you think it should be measuring different levels?
https://github.com/llvm/llvm-project/pull/94954
More information about the llvm-commits
mailing list