aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Instructions.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-09-20 15:21:52 +0000
committerSanjay Patel <spatel@rotateright.com>2018-09-20 15:21:52 +0000
commitfd4976bd191f98b1981db1c60027bbe643c98b9d (patch)
tree0008366babaa801537e94123d7e03380559c8ca7 /llvm/lib/IR/Instructions.cpp
parent468f53b58c620031c11e47b3c3f27271797b0771 (diff)
downloadllvm-fd4976bd191f98b1981db1c60027bbe643c98b9d.zip
llvm-fd4976bd191f98b1981db1c60027bbe643c98b9d.tar.gz
llvm-fd4976bd191f98b1981db1c60027bbe643c98b9d.tar.bz2
[IR] add shuffle query for vector concatenation
This can be used for combining and in the vectorizers/cost models. llvm-svn: 342653
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r--llvm/lib/IR/Instructions.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 266345b..8ade6f5 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -1801,6 +1801,23 @@ bool ShuffleVectorInst::isIdentityWithExtract() const {
return isIdentityMaskImpl(getShuffleMask(), NumOpElts);
}
+bool ShuffleVectorInst::isConcat() const {
+ // Vector concatenation is differentiated from identity with padding.
+ if (isa<UndefValue>(Op<0>()) || isa<UndefValue>(Op<1>()))
+ return false;
+
+ int NumOpElts = Op<0>()->getType()->getVectorNumElements();
+ int NumMaskElts = getType()->getVectorNumElements();
+ if (NumMaskElts != NumOpElts * 2)
+ return false;
+
+ // Use the mask length rather than the operands' vector lengths here. We
+ // already know that the shuffle returns a vector twice as long as the inputs,
+ // and neither of the inputs are undef vectors. If the mask picks consecutive
+ // elements from both inputs, then this is a concatenation of the inputs.
+ return isIdentityMaskImpl(getShuffleMask(), NumMaskElts);
+}
+
//===----------------------------------------------------------------------===//
// InsertValueInst Class
//===----------------------------------------------------------------------===//