}
/// Return true if this shuffle mask is a replication mask.
- bool isReplicationMask(int &ReplicationFactor, int &VF) const {
- // Not possible to express a shuffle mask for a scalable vector for this
- // case.
- if (isa<ScalableVectorType>(getType()))
- return false;
-
- return isReplicationMask(ShuffleMask, ReplicationFactor, VF);
- }
+ bool isReplicationMask(int &ReplicationFactor, int &VF) const;
/// Change values in a shuffle permute mask assuming the two vector operands
/// of length InVecNumElts have swapped position.
return false;
}
+bool ShuffleVectorInst::isReplicationMask(int &ReplicationFactor,
+ int &VF) const {
+ // Not possible to express a shuffle mask for a scalable vector for this
+ // case.
+ if (isa<ScalableVectorType>(getType()))
+ return false;
+
+ VF = cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
+ if (ShuffleMask.size() % VF != 0)
+ return false;
+ ReplicationFactor = ShuffleMask.size() / VF;
+
+ return isReplicationMaskWithParams(ShuffleMask, ReplicationFactor, VF);
+}
+
//===----------------------------------------------------------------------===//
// InsertValueInst Class
//===----------------------------------------------------------------------===//
ReplicatedMask, GuessedReplicationFactor, GuessedVF));
EXPECT_EQ(GuessedReplicationFactor, ReplicationFactor);
EXPECT_EQ(GuessedVF, VF);
+
+ for (int OpVF : seq_inclusive(VF, 2 * VF + 1)) {
+ LLVMContext Ctx;
+ Type *OpVFTy = FixedVectorType::get(IntegerType::getInt1Ty(Ctx), OpVF);
+ Value *Op = ConstantVector::getNullValue(OpVFTy);
+ ShuffleVectorInst *SVI = new ShuffleVectorInst(Op, Op, ReplicatedMask);
+ EXPECT_EQ(SVI->isReplicationMask(GuessedReplicationFactor, GuessedVF),
+ OpVF == VF);
+ delete SVI;
+ }
}
}
}