mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[SVE] Remove calls to VectorType::getNumElements from IR
Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D81500
This commit is contained in:
parent
9b9f0675a4
commit
c849a98c1b
@ -78,7 +78,8 @@ public:
|
||||
bool isMinSignedValue() const;
|
||||
|
||||
/// Return true if this is a finite and non-zero floating-point scalar
|
||||
/// constant or a vector constant with all finite and non-zero elements.
|
||||
/// constant or a fixed width vector constant with all finite and non-zero
|
||||
/// elements.
|
||||
bool isFiniteNonZeroFP() const;
|
||||
|
||||
/// Return true if this is a normal (as opposed to denormal) floating-point
|
||||
@ -100,11 +101,13 @@ public:
|
||||
bool isElementWiseEqual(Value *Y) const;
|
||||
|
||||
/// Return true if this is a vector constant that includes any undefined
|
||||
/// elements.
|
||||
/// elements. Since it is impossible to inspect a scalable vector element-
|
||||
/// wise at compile time, this function returns true only if the entire
|
||||
/// vector is undef
|
||||
bool containsUndefElement() const;
|
||||
|
||||
/// Return true if this is a vector constant that includes any constant
|
||||
/// expressions.
|
||||
/// Return true if this is a fixed width vector constant that includes
|
||||
/// any constant expressions.
|
||||
bool containsConstantExpression() const;
|
||||
|
||||
/// Return true if evaluation of this constant could trap. This is true for
|
||||
|
@ -83,7 +83,7 @@ namespace llvm {
|
||||
if (isa<ScalableVectorType>(VTy))
|
||||
NumElements = Unbounded;
|
||||
else
|
||||
NumElements = VTy->getNumElements();
|
||||
NumElements = cast<FixedVectorType>(VTy)->getNumElements();
|
||||
} else
|
||||
CurTy = dyn_cast<StructType>(Ty);
|
||||
++OpIt;
|
||||
|
@ -2057,7 +2057,7 @@ public:
|
||||
/// Example: shufflevector <2 x n> A, <2 x n> B, <1,2,3>
|
||||
bool increasesLength() const {
|
||||
unsigned NumSourceElts =
|
||||
cast<VectorType>(Op<0>()->getType())->getNumElements();
|
||||
cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
|
||||
unsigned NumMaskElts = ShuffleMask.size();
|
||||
return NumSourceElts < NumMaskElts;
|
||||
}
|
||||
@ -2250,7 +2250,8 @@ public:
|
||||
|
||||
/// Return true if this shuffle mask is an extract subvector mask.
|
||||
bool isExtractSubvectorMask(int &Index) const {
|
||||
int NumSrcElts = cast<VectorType>(Op<0>()->getType())->getNumElements();
|
||||
int NumSrcElts =
|
||||
cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
|
||||
return isExtractSubvectorMask(ShuffleMask, NumSrcElts, Index);
|
||||
}
|
||||
|
||||
|
@ -38,14 +38,19 @@ template <class IRBuilderTy> class MatrixBuilder {
|
||||
Value *RHS) {
|
||||
assert((LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy()) &&
|
||||
"One of the operands must be a matrix (embedded in a vector)");
|
||||
if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
|
||||
if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy()) {
|
||||
assert(!isa<ScalableVectorType>(LHS->getType()) &&
|
||||
"LHS Assumed to be fixed width");
|
||||
RHS = B.CreateVectorSplat(
|
||||
cast<VectorType>(LHS->getType())->getNumElements(), RHS,
|
||||
cast<VectorType>(LHS->getType())->getElementCount(), RHS,
|
||||
"scalar.splat");
|
||||
else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
|
||||
} else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy()) {
|
||||
assert(!isa<ScalableVectorType>(RHS->getType()) &&
|
||||
"RHS Assumed to be fixed width");
|
||||
LHS = B.CreateVectorSplat(
|
||||
cast<VectorType>(RHS->getType())->getNumElements(), LHS,
|
||||
cast<VectorType>(RHS->getType())->getElementCount(), LHS,
|
||||
"scalar.splat");
|
||||
}
|
||||
return {LHS, RHS};
|
||||
}
|
||||
|
||||
@ -155,14 +160,19 @@ public:
|
||||
/// matrixes.
|
||||
Value *CreateAdd(Value *LHS, Value *RHS) {
|
||||
assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
|
||||
if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
|
||||
if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy()) {
|
||||
assert(!isa<ScalableVectorType>(LHS->getType()) &&
|
||||
"LHS Assumed to be fixed width");
|
||||
RHS = B.CreateVectorSplat(
|
||||
cast<VectorType>(LHS->getType())->getNumElements(), RHS,
|
||||
cast<VectorType>(LHS->getType())->getElementCount(), RHS,
|
||||
"scalar.splat");
|
||||
else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
|
||||
} else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy()) {
|
||||
assert(!isa<ScalableVectorType>(RHS->getType()) &&
|
||||
"RHS Assumed to be fixed width");
|
||||
LHS = B.CreateVectorSplat(
|
||||
cast<VectorType>(RHS->getType())->getNumElements(), LHS,
|
||||
cast<VectorType>(RHS->getType())->getElementCount(), LHS,
|
||||
"scalar.splat");
|
||||
}
|
||||
|
||||
return cast<VectorType>(LHS->getType())
|
||||
->getElementType()
|
||||
@ -175,14 +185,19 @@ public:
|
||||
/// point matrixes.
|
||||
Value *CreateSub(Value *LHS, Value *RHS) {
|
||||
assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
|
||||
if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
|
||||
if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy()) {
|
||||
assert(!isa<ScalableVectorType>(LHS->getType()) &&
|
||||
"LHS Assumed to be fixed width");
|
||||
RHS = B.CreateVectorSplat(
|
||||
cast<VectorType>(LHS->getType())->getNumElements(), RHS,
|
||||
cast<VectorType>(LHS->getType())->getElementCount(), RHS,
|
||||
"scalar.splat");
|
||||
else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
|
||||
} else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy()) {
|
||||
assert(!isa<ScalableVectorType>(RHS->getType()) &&
|
||||
"RHS Assumed to be fixed width");
|
||||
LHS = B.CreateVectorSplat(
|
||||
cast<VectorType>(RHS->getType())->getNumElements(), LHS,
|
||||
cast<VectorType>(RHS->getType())->getElementCount(), LHS,
|
||||
"scalar.splat");
|
||||
}
|
||||
|
||||
return cast<VectorType>(LHS->getType())
|
||||
->getElementType()
|
||||
|
@ -1511,7 +1511,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
|
||||
}
|
||||
|
||||
if (isa<ConstantVector>(CV) || isa<ConstantDataVector>(CV)) {
|
||||
auto *CVVTy = cast<VectorType>(CV->getType());
|
||||
auto *CVVTy = cast<FixedVectorType>(CV->getType());
|
||||
Type *ETy = CVVTy->getElementType();
|
||||
Out << '<';
|
||||
TypePrinter.print(ETy, Out);
|
||||
|
@ -988,7 +988,7 @@ GlobalVariable *llvm::UpgradeGlobalVariable(GlobalVariable *GV) {
|
||||
// to byte shuffles.
|
||||
static Value *UpgradeX86PSLLDQIntrinsics(IRBuilder<> &Builder,
|
||||
Value *Op, unsigned Shift) {
|
||||
auto *ResultTy = cast<VectorType>(Op->getType());
|
||||
auto *ResultTy = cast<FixedVectorType>(Op->getType());
|
||||
unsigned NumElts = ResultTy->getNumElements() * 8;
|
||||
|
||||
// Bitcast from a 64-bit element type to a byte element type.
|
||||
@ -1022,7 +1022,7 @@ static Value *UpgradeX86PSLLDQIntrinsics(IRBuilder<> &Builder,
|
||||
// to byte shuffles.
|
||||
static Value *UpgradeX86PSRLDQIntrinsics(IRBuilder<> &Builder, Value *Op,
|
||||
unsigned Shift) {
|
||||
auto *ResultTy = cast<VectorType>(Op->getType());
|
||||
auto *ResultTy = cast<FixedVectorType>(Op->getType());
|
||||
unsigned NumElts = ResultTy->getNumElements() * 8;
|
||||
|
||||
// Bitcast from a 64-bit element type to a byte element type.
|
||||
@ -1080,7 +1080,7 @@ static Value *EmitX86Select(IRBuilder<> &Builder, Value *Mask,
|
||||
return Op0;
|
||||
|
||||
Mask = getX86MaskVec(Builder, Mask,
|
||||
cast<VectorType>(Op0->getType())->getNumElements());
|
||||
cast<FixedVectorType>(Op0->getType())->getNumElements());
|
||||
return Builder.CreateSelect(Mask, Op0, Op1);
|
||||
}
|
||||
|
||||
@ -1107,7 +1107,7 @@ static Value *UpgradeX86ALIGNIntrinsics(IRBuilder<> &Builder, Value *Op0,
|
||||
bool IsVALIGN) {
|
||||
unsigned ShiftVal = cast<llvm::ConstantInt>(Shift)->getZExtValue();
|
||||
|
||||
unsigned NumElts = cast<VectorType>(Op0->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(Op0->getType())->getNumElements();
|
||||
assert((IsVALIGN || NumElts % 16 == 0) && "Illegal NumElts for PALIGNR!");
|
||||
assert((!IsVALIGN || NumElts <= 16) && "NumElts too large for VALIGN!");
|
||||
assert(isPowerOf2_32(NumElts) && "NumElts not a power of 2!");
|
||||
@ -1238,7 +1238,7 @@ static Value *upgradeX86Rotate(IRBuilder<> &Builder, CallInst &CI,
|
||||
// Funnel shifts amounts are treated as modulo and types are all power-of-2 so
|
||||
// we only care about the lowest log2 bits anyway.
|
||||
if (Amt->getType() != Ty) {
|
||||
unsigned NumElts = cast<VectorType>(Ty)->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
|
||||
Amt = Builder.CreateIntCast(Amt, Ty->getScalarType(), false);
|
||||
Amt = Builder.CreateVectorSplat(NumElts, Amt);
|
||||
}
|
||||
@ -1308,7 +1308,7 @@ static Value *upgradeX86ConcatShift(IRBuilder<> &Builder, CallInst &CI,
|
||||
// Funnel shifts amounts are treated as modulo and types are all power-of-2 so
|
||||
// we only care about the lowest log2 bits anyway.
|
||||
if (Amt->getType() != Ty) {
|
||||
unsigned NumElts = cast<VectorType>(Ty)->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
|
||||
Amt = Builder.CreateIntCast(Amt, Ty->getScalarType(), false);
|
||||
Amt = Builder.CreateVectorSplat(NumElts, Amt);
|
||||
}
|
||||
@ -1345,7 +1345,7 @@ static Value *UpgradeMaskedStore(IRBuilder<> &Builder,
|
||||
return Builder.CreateAlignedStore(Data, Ptr, Alignment);
|
||||
|
||||
// Convert the mask from an integer type to a vector of i1.
|
||||
unsigned NumElts = cast<VectorType>(Data->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(Data->getType())->getNumElements();
|
||||
Mask = getX86MaskVec(Builder, Mask, NumElts);
|
||||
return Builder.CreateMaskedStore(Data, Ptr, Alignment, Mask);
|
||||
}
|
||||
@ -1368,7 +1368,8 @@ static Value *UpgradeMaskedLoad(IRBuilder<> &Builder,
|
||||
return Builder.CreateAlignedLoad(ValTy, Ptr, Alignment);
|
||||
|
||||
// Convert the mask from an integer type to a vector of i1.
|
||||
unsigned NumElts = cast<VectorType>(Passthru->getType())->getNumElements();
|
||||
unsigned NumElts =
|
||||
cast<FixedVectorType>(Passthru->getType())->getNumElements();
|
||||
Mask = getX86MaskVec(Builder, Mask, NumElts);
|
||||
return Builder.CreateMaskedLoad(Ptr, Alignment, Mask, Passthru);
|
||||
}
|
||||
@ -1432,7 +1433,7 @@ static Value *upgradePMULDQ(IRBuilder<> &Builder, CallInst &CI, bool IsSigned) {
|
||||
// Applying mask on vector of i1's and make sure result is at least 8 bits wide.
|
||||
static Value *ApplyX86MaskOn1BitsVec(IRBuilder<> &Builder, Value *Vec,
|
||||
Value *Mask) {
|
||||
unsigned NumElts = cast<VectorType>(Vec->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(Vec->getType())->getNumElements();
|
||||
if (Mask) {
|
||||
const auto *C = dyn_cast<Constant>(Mask);
|
||||
if (!C || !C->isAllOnesValue())
|
||||
@ -1455,7 +1456,7 @@ static Value *ApplyX86MaskOn1BitsVec(IRBuilder<> &Builder, Value *Vec,
|
||||
static Value *upgradeMaskedCompare(IRBuilder<> &Builder, CallInst &CI,
|
||||
unsigned CC, bool Signed) {
|
||||
Value *Op0 = CI.getArgOperand(0);
|
||||
unsigned NumElts = cast<VectorType>(Op0->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(Op0->getType())->getNumElements();
|
||||
|
||||
Value *Cmp;
|
||||
if (CC == 3) {
|
||||
@ -1510,7 +1511,7 @@ static Value* upgradeMaskedMove(IRBuilder<> &Builder, CallInst &CI) {
|
||||
static Value* UpgradeMaskToInt(IRBuilder<> &Builder, CallInst &CI) {
|
||||
Value* Op = CI.getArgOperand(0);
|
||||
Type* ReturnOp = CI.getType();
|
||||
unsigned NumElts = cast<VectorType>(CI.getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(CI.getType())->getNumElements();
|
||||
Value *Mask = getX86MaskVec(Builder, Op, NumElts);
|
||||
return Builder.CreateSExt(Mask, ReturnOp, "vpmovm2");
|
||||
}
|
||||
@ -1959,8 +1960,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Rep = Builder.CreateICmp(Pred, Rep, Zero);
|
||||
Rep = ApplyX86MaskOn1BitsVec(Builder, Rep, Mask);
|
||||
} else if (IsX86 && (Name.startswith("avx512.mask.pbroadcast"))){
|
||||
unsigned NumElts =
|
||||
cast<VectorType>(CI->getArgOperand(1)->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(CI->getArgOperand(1)->getType())
|
||||
->getNumElements();
|
||||
Rep = Builder.CreateVectorSplat(NumElts, CI->getArgOperand(0));
|
||||
Rep = EmitX86Select(Builder, CI->getArgOperand(2), Rep,
|
||||
CI->getArgOperand(1));
|
||||
@ -2208,9 +2209,9 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name == "avx.cvt.ps2.pd.256" ||
|
||||
Name == "avx512.mask.cvtps2pd.128" ||
|
||||
Name == "avx512.mask.cvtps2pd.256")) {
|
||||
auto *DstTy = cast<VectorType>(CI->getType());
|
||||
auto *DstTy = cast<FixedVectorType>(CI->getType());
|
||||
Rep = CI->getArgOperand(0);
|
||||
auto *SrcTy = cast<VectorType>(Rep->getType());
|
||||
auto *SrcTy = cast<FixedVectorType>(Rep->getType());
|
||||
|
||||
unsigned NumDstElts = DstTy->getNumElements();
|
||||
if (NumDstElts < SrcTy->getNumElements()) {
|
||||
@ -2240,9 +2241,9 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
CI->getArgOperand(1));
|
||||
} else if (IsX86 && (Name.startswith("avx512.mask.vcvtph2ps.") ||
|
||||
Name.startswith("vcvtph2ps."))) {
|
||||
auto *DstTy = cast<VectorType>(CI->getType());
|
||||
auto *DstTy = cast<FixedVectorType>(CI->getType());
|
||||
Rep = CI->getArgOperand(0);
|
||||
auto *SrcTy = cast<VectorType>(Rep->getType());
|
||||
auto *SrcTy = cast<FixedVectorType>(Rep->getType());
|
||||
unsigned NumDstElts = DstTy->getNumElements();
|
||||
if (NumDstElts != SrcTy->getNumElements()) {
|
||||
assert(NumDstElts == 4 && "Unexpected vector size");
|
||||
@ -2263,7 +2264,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
CI->getArgOperand(1),CI->getArgOperand(2),
|
||||
/*Aligned*/true);
|
||||
} else if (IsX86 && Name.startswith("avx512.mask.expand.load.")) {
|
||||
auto *ResultTy = cast<VectorType>(CI->getType());
|
||||
auto *ResultTy = cast<FixedVectorType>(CI->getType());
|
||||
Type *PtrTy = ResultTy->getElementType();
|
||||
|
||||
// Cast the pointer to element type.
|
||||
@ -2285,8 +2286,9 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Value *Ptr = Builder.CreateBitCast(CI->getOperand(0),
|
||||
llvm::PointerType::getUnqual(PtrTy));
|
||||
|
||||
Value *MaskVec = getX86MaskVec(Builder, CI->getArgOperand(2),
|
||||
ResultTy->getNumElements());
|
||||
Value *MaskVec =
|
||||
getX86MaskVec(Builder, CI->getArgOperand(2),
|
||||
cast<FixedVectorType>(ResultTy)->getNumElements());
|
||||
|
||||
Function *CSt = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::masked_compressstore,
|
||||
@ -2294,7 +2296,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Rep = Builder.CreateCall(CSt, { CI->getArgOperand(1), Ptr, MaskVec });
|
||||
} else if (IsX86 && (Name.startswith("avx512.mask.compress.") ||
|
||||
Name.startswith("avx512.mask.expand."))) {
|
||||
auto *ResultTy = cast<VectorType>(CI->getType());
|
||||
auto *ResultTy = cast<FixedVectorType>(CI->getType());
|
||||
|
||||
Value *MaskVec = getX86MaskVec(Builder, CI->getArgOperand(2),
|
||||
ResultTy->getNumElements());
|
||||
@ -2374,7 +2376,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
} else if (IsX86 && (Name.startswith("avx.vbroadcast.s") ||
|
||||
Name.startswith("avx512.vbroadcast.s"))) {
|
||||
// Replace broadcasts with a series of insertelements.
|
||||
auto *VecTy = cast<VectorType>(CI->getType());
|
||||
auto *VecTy = cast<FixedVectorType>(CI->getType());
|
||||
Type *EltTy = VecTy->getElementType();
|
||||
unsigned EltNum = VecTy->getNumElements();
|
||||
Value *Cast = Builder.CreateBitCast(CI->getArgOperand(0),
|
||||
@ -2391,8 +2393,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx2.pmovzx") ||
|
||||
Name.startswith("avx512.mask.pmovsx") ||
|
||||
Name.startswith("avx512.mask.pmovzx"))) {
|
||||
VectorType *SrcTy = cast<VectorType>(CI->getArgOperand(0)->getType());
|
||||
VectorType *DstTy = cast<VectorType>(CI->getType());
|
||||
auto *SrcTy = cast<FixedVectorType>(CI->getArgOperand(0)->getType());
|
||||
auto *DstTy = cast<FixedVectorType>(CI->getType());
|
||||
unsigned NumDstElts = DstTy->getNumElements();
|
||||
|
||||
// Extract a subvector of the first NumDstElts lanes and sign/zero extend.
|
||||
@ -2459,8 +2461,10 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
}else if (IsX86 && (Name.startswith("avx512.mask.broadcastf") ||
|
||||
Name.startswith("avx512.mask.broadcasti"))) {
|
||||
unsigned NumSrcElts =
|
||||
cast<VectorType>(CI->getArgOperand(0)->getType())->getNumElements();
|
||||
unsigned NumDstElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
cast<FixedVectorType>(CI->getArgOperand(0)->getType())
|
||||
->getNumElements();
|
||||
unsigned NumDstElts =
|
||||
cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
|
||||
SmallVector<int, 8> ShuffleMask(NumDstElts);
|
||||
for (unsigned i = 0; i != NumDstElts; ++i)
|
||||
@ -2549,7 +2553,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
Value *Op1 = CI->getArgOperand(1);
|
||||
unsigned Imm = cast <ConstantInt>(CI->getArgOperand(2))->getZExtValue();
|
||||
VectorType *VecTy = cast<VectorType>(CI->getType());
|
||||
auto *VecTy = cast<FixedVectorType>(CI->getType());
|
||||
unsigned NumElts = VecTy->getNumElements();
|
||||
|
||||
SmallVector<int, 16> Idxs(NumElts);
|
||||
@ -2563,8 +2567,10 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
Value *Op1 = CI->getArgOperand(1);
|
||||
unsigned Imm = cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
|
||||
unsigned DstNumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
unsigned SrcNumElts = cast<VectorType>(Op1->getType())->getNumElements();
|
||||
unsigned DstNumElts =
|
||||
cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
unsigned SrcNumElts =
|
||||
cast<FixedVectorType>(Op1->getType())->getNumElements();
|
||||
unsigned Scale = DstNumElts / SrcNumElts;
|
||||
|
||||
// Mask off the high bits of the immediate value; hardware ignores those.
|
||||
@ -2607,8 +2613,10 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx512.mask.vextract"))) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
unsigned Imm = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
|
||||
unsigned DstNumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
unsigned SrcNumElts = cast<VectorType>(Op0->getType())->getNumElements();
|
||||
unsigned DstNumElts =
|
||||
cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
unsigned SrcNumElts =
|
||||
cast<FixedVectorType>(Op0->getType())->getNumElements();
|
||||
unsigned Scale = SrcNumElts / DstNumElts;
|
||||
|
||||
// Mask off the high bits of the immediate value; hardware ignores those.
|
||||
@ -2631,7 +2639,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx512.mask.perm.di."))) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
unsigned Imm = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
|
||||
VectorType *VecTy = cast<VectorType>(CI->getType());
|
||||
auto *VecTy = cast<FixedVectorType>(CI->getType());
|
||||
unsigned NumElts = VecTy->getNumElements();
|
||||
|
||||
SmallVector<int, 8> Idxs(NumElts);
|
||||
@ -2655,7 +2663,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
|
||||
uint8_t Imm = cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
|
||||
|
||||
unsigned NumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
unsigned HalfSize = NumElts / 2;
|
||||
SmallVector<int, 8> ShuffleMask(NumElts);
|
||||
|
||||
@ -2685,7 +2693,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx512.mask.pshuf.d."))) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
unsigned Imm = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
|
||||
VectorType *VecTy = cast<VectorType>(CI->getType());
|
||||
auto *VecTy = cast<FixedVectorType>(CI->getType());
|
||||
unsigned NumElts = VecTy->getNumElements();
|
||||
// Calculate the size of each index in the immediate.
|
||||
unsigned IdxSize = 64 / VecTy->getScalarSizeInBits();
|
||||
@ -2707,7 +2715,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx512.mask.pshufl.w."))) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
unsigned Imm = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
|
||||
unsigned NumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
|
||||
SmallVector<int, 16> Idxs(NumElts);
|
||||
for (unsigned l = 0; l != NumElts; l += 8) {
|
||||
@ -2726,7 +2734,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx512.mask.pshufh.w."))) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
unsigned Imm = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
|
||||
unsigned NumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
|
||||
SmallVector<int, 16> Idxs(NumElts);
|
||||
for (unsigned l = 0; l != NumElts; l += 8) {
|
||||
@ -2745,7 +2753,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
Value *Op1 = CI->getArgOperand(1);
|
||||
unsigned Imm = cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
|
||||
unsigned NumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
|
||||
unsigned NumLaneElts = 128/CI->getType()->getScalarSizeInBits();
|
||||
unsigned HalfLaneElts = NumLaneElts / 2;
|
||||
@ -2770,7 +2778,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx512.mask.movshdup") ||
|
||||
Name.startswith("avx512.mask.movsldup"))) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
unsigned NumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
unsigned NumLaneElts = 128/CI->getType()->getScalarSizeInBits();
|
||||
|
||||
unsigned Offset = 0;
|
||||
@ -2792,7 +2800,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx512.mask.unpckl."))) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
Value *Op1 = CI->getArgOperand(1);
|
||||
int NumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
int NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
int NumLaneElts = 128/CI->getType()->getScalarSizeInBits();
|
||||
|
||||
SmallVector<int, 64> Idxs(NumElts);
|
||||
@ -2808,7 +2816,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Name.startswith("avx512.mask.unpckh."))) {
|
||||
Value *Op0 = CI->getArgOperand(0);
|
||||
Value *Op1 = CI->getArgOperand(1);
|
||||
int NumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
int NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
int NumLaneElts = 128/CI->getType()->getScalarSizeInBits();
|
||||
|
||||
SmallVector<int, 64> Idxs(NumElts);
|
||||
@ -3376,7 +3384,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
Ops);
|
||||
} else {
|
||||
int NumElts = cast<VectorType>(CI->getType())->getNumElements();
|
||||
int NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
|
||||
Value *Ops[] = { CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2) };
|
||||
@ -3832,7 +3840,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
case Intrinsic::x86_avx512_mask_cmp_ps_512: {
|
||||
SmallVector<Value *, 4> Args(CI->arg_operands().begin(),
|
||||
CI->arg_operands().end());
|
||||
unsigned NumElts = cast<VectorType>(Args[0]->getType())->getNumElements();
|
||||
unsigned NumElts =
|
||||
cast<FixedVectorType>(Args[0]->getType())->getNumElements();
|
||||
Args[3] = getX86MaskVec(Builder, Args[3], NumElts);
|
||||
|
||||
NewCall = Builder.CreateCall(NewFn, Args);
|
||||
|
@ -161,7 +161,7 @@ bool Constant::isNotOneValue() const {
|
||||
|
||||
// Check that vectors don't contain 1
|
||||
if (auto *VTy = dyn_cast<VectorType>(this->getType())) {
|
||||
unsigned NumElts = VTy->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(VTy)->getNumElements();
|
||||
for (unsigned i = 0; i != NumElts; ++i) {
|
||||
Constant *Elt = this->getAggregateElement(i);
|
||||
if (!Elt || !Elt->isNotOneValue())
|
||||
@ -211,7 +211,7 @@ bool Constant::isNotMinSignedValue() const {
|
||||
|
||||
// Check that vectors don't contain INT_MIN
|
||||
if (auto *VTy = dyn_cast<VectorType>(this->getType())) {
|
||||
unsigned NumElts = VTy->getNumElements();
|
||||
unsigned NumElts = cast<FixedVectorType>(VTy)->getNumElements();
|
||||
for (unsigned i = 0; i != NumElts; ++i) {
|
||||
Constant *Elt = this->getAggregateElement(i);
|
||||
if (!Elt || !Elt->isNotMinSignedValue())
|
||||
@ -227,7 +227,7 @@ bool Constant::isNotMinSignedValue() const {
|
||||
bool Constant::isFiniteNonZeroFP() const {
|
||||
if (auto *CFP = dyn_cast<ConstantFP>(this))
|
||||
return CFP->getValueAPF().isFiniteNonZero();
|
||||
auto *VTy = dyn_cast<VectorType>(getType());
|
||||
auto *VTy = dyn_cast<FixedVectorType>(getType());
|
||||
if (!VTy)
|
||||
return false;
|
||||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
@ -306,7 +306,15 @@ bool Constant::isElementWiseEqual(Value *Y) const {
|
||||
|
||||
bool Constant::containsUndefElement() const {
|
||||
if (auto *VTy = dyn_cast<VectorType>(getType())) {
|
||||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)
|
||||
if (isa<UndefValue>(this))
|
||||
return true;
|
||||
if (isa<ConstantAggregateZero>(this))
|
||||
return false;
|
||||
if (isa<ScalableVectorType>(getType()))
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0, e = cast<FixedVectorType>(VTy)->getNumElements();
|
||||
i != e; ++i)
|
||||
if (isa<UndefValue>(getAggregateElement(i)))
|
||||
return true;
|
||||
}
|
||||
@ -315,7 +323,7 @@ bool Constant::containsUndefElement() const {
|
||||
}
|
||||
|
||||
bool Constant::containsConstantExpression() const {
|
||||
if (auto *VTy = dyn_cast<VectorType>(getType())) {
|
||||
if (auto *VTy = dyn_cast<FixedVectorType>(getType())) {
|
||||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)
|
||||
if (isa<ConstantExpr>(getAggregateElement(i)))
|
||||
return true;
|
||||
@ -1029,7 +1037,7 @@ unsigned ConstantAggregateZero::getNumElements() const {
|
||||
if (auto *AT = dyn_cast<ArrayType>(Ty))
|
||||
return AT->getNumElements();
|
||||
if (auto *VT = dyn_cast<VectorType>(Ty))
|
||||
return VT->getNumElements();
|
||||
return cast<FixedVectorType>(VT)->getNumElements();
|
||||
return Ty->getStructNumElements();
|
||||
}
|
||||
|
||||
@ -1064,7 +1072,7 @@ unsigned UndefValue::getNumElements() const {
|
||||
if (auto *AT = dyn_cast<ArrayType>(Ty))
|
||||
return AT->getNumElements();
|
||||
if (auto *VT = dyn_cast<VectorType>(Ty))
|
||||
return VT->getNumElements();
|
||||
return cast<FixedVectorType>(VT)->getNumElements();
|
||||
return Ty->getStructNumElements();
|
||||
}
|
||||
|
||||
@ -1246,7 +1254,7 @@ Constant *ConstantStruct::get(StructType *ST, ArrayRef<Constant*> V) {
|
||||
|
||||
ConstantVector::ConstantVector(VectorType *T, ArrayRef<Constant *> V)
|
||||
: ConstantAggregate(T, ConstantVectorVal, V) {
|
||||
assert(V.size() == T->getNumElements() &&
|
||||
assert(V.size() == cast<FixedVectorType>(T)->getNumElements() &&
|
||||
"Invalid initializer for constant vector");
|
||||
}
|
||||
|
||||
@ -2004,8 +2012,8 @@ Constant *ConstantExpr::getPtrToInt(Constant *C, Type *DstTy,
|
||||
"PtrToInt destination must be integer or integer vector");
|
||||
assert(isa<VectorType>(C->getType()) == isa<VectorType>(DstTy));
|
||||
if (isa<VectorType>(C->getType()))
|
||||
assert(cast<VectorType>(C->getType())->getNumElements() ==
|
||||
cast<VectorType>(DstTy)->getNumElements() &&
|
||||
assert(cast<FixedVectorType>(C->getType())->getNumElements() ==
|
||||
cast<FixedVectorType>(DstTy)->getNumElements() &&
|
||||
"Invalid cast between a different number of vector elements");
|
||||
return getFoldedCast(Instruction::PtrToInt, C, DstTy, OnlyIfReduced);
|
||||
}
|
||||
@ -2018,8 +2026,8 @@ Constant *ConstantExpr::getIntToPtr(Constant *C, Type *DstTy,
|
||||
"IntToPtr destination must be a pointer or pointer vector");
|
||||
assert(isa<VectorType>(C->getType()) == isa<VectorType>(DstTy));
|
||||
if (isa<VectorType>(C->getType()))
|
||||
assert(cast<VectorType>(C->getType())->getNumElements() ==
|
||||
cast<VectorType>(DstTy)->getNumElements() &&
|
||||
assert(cast<VectorType>(C->getType())->getElementCount() ==
|
||||
cast<VectorType>(DstTy)->getElementCount() &&
|
||||
"Invalid cast between a different number of vector elements");
|
||||
return getFoldedCast(Instruction::IntToPtr, C, DstTy, OnlyIfReduced);
|
||||
}
|
||||
@ -2050,7 +2058,8 @@ Constant *ConstantExpr::getAddrSpaceCast(Constant *C, Type *DstTy,
|
||||
Type *MidTy = PointerType::get(DstElemTy, SrcScalarTy->getAddressSpace());
|
||||
if (VectorType *VT = dyn_cast<VectorType>(DstTy)) {
|
||||
// Handle vectors of pointers.
|
||||
MidTy = FixedVectorType::get(MidTy, VT->getNumElements());
|
||||
MidTy = FixedVectorType::get(MidTy,
|
||||
cast<FixedVectorType>(VT)->getNumElements());
|
||||
}
|
||||
C = getBitCast(C, MidTy);
|
||||
}
|
||||
@ -2692,7 +2701,7 @@ bool ConstantDataSequential::isElementTypeCompatible(Type *Ty) {
|
||||
unsigned ConstantDataSequential::getNumElements() const {
|
||||
if (ArrayType *AT = dyn_cast<ArrayType>(getType()))
|
||||
return AT->getNumElements();
|
||||
return cast<VectorType>(getType())->getNumElements();
|
||||
return cast<FixedVectorType>(getType())->getNumElements();
|
||||
}
|
||||
|
||||
|
||||
|
@ -781,7 +781,7 @@ unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy) {
|
||||
}
|
||||
|
||||
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy) {
|
||||
return unwrap<VectorType>(VectorTy)->getNumElements();
|
||||
return unwrap<VectorType>(VectorTy)->getElementCount().Min;
|
||||
}
|
||||
|
||||
/*--.. Operations on other types ...........................................--*/
|
||||
|
@ -1396,10 +1396,11 @@ static bool matchIntrinsicType(
|
||||
// Verify the overloaded type "matches" the Ref type.
|
||||
// i.e. Ty is a vector with the same width as Ref.
|
||||
// Composed of pointers to the same element type as Ref.
|
||||
VectorType *ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
|
||||
VectorType *ThisArgVecTy = dyn_cast<VectorType>(Ty);
|
||||
auto *ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
|
||||
auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
|
||||
if (!ThisArgVecTy || !ReferenceType ||
|
||||
(ReferenceType->getNumElements() != ThisArgVecTy->getNumElements()))
|
||||
(cast<FixedVectorType>(ReferenceType)->getNumElements() !=
|
||||
cast<FixedVectorType>(ThisArgVecTy)->getNumElements()))
|
||||
return true;
|
||||
PointerType *ThisArgEltTy =
|
||||
dyn_cast<PointerType>(ThisArgVecTy->getElementType());
|
||||
|
@ -523,8 +523,8 @@ CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
|
||||
CallInst *IRBuilderBase::CreateMaskedGather(Value *Ptrs, Align Alignment,
|
||||
Value *Mask, Value *PassThru,
|
||||
const Twine &Name) {
|
||||
auto PtrsTy = cast<VectorType>(Ptrs->getType());
|
||||
auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
|
||||
auto *PtrsTy = cast<FixedVectorType>(Ptrs->getType());
|
||||
auto *PtrTy = cast<PointerType>(PtrsTy->getElementType());
|
||||
unsigned NumElts = PtrsTy->getNumElements();
|
||||
auto *DataTy = FixedVectorType::get(PtrTy->getElementType(), NumElts);
|
||||
|
||||
@ -553,8 +553,8 @@ CallInst *IRBuilderBase::CreateMaskedGather(Value *Ptrs, Align Alignment,
|
||||
/// be accessed in memory
|
||||
CallInst *IRBuilderBase::CreateMaskedScatter(Value *Data, Value *Ptrs,
|
||||
Align Alignment, Value *Mask) {
|
||||
auto PtrsTy = cast<VectorType>(Ptrs->getType());
|
||||
auto DataTy = cast<VectorType>(Data->getType());
|
||||
auto *PtrsTy = cast<FixedVectorType>(Ptrs->getType());
|
||||
auto *DataTy = cast<FixedVectorType>(Data->getType());
|
||||
unsigned NumElts = PtrsTy->getNumElements();
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -1943,7 +1943,7 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, ArrayRef<int> Mask,
|
||||
}
|
||||
|
||||
void ShuffleVectorInst::commute() {
|
||||
int NumOpElts = cast<VectorType>(Op<0>()->getType())->getNumElements();
|
||||
int NumOpElts = cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
|
||||
int NumMaskElts = ShuffleMask.size();
|
||||
SmallVector<int, 16> NewMask(NumMaskElts);
|
||||
for (int i = 0; i != NumMaskElts; ++i) {
|
||||
@ -1997,7 +1997,7 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
|
||||
return true;
|
||||
|
||||
if (const auto *MV = dyn_cast<ConstantVector>(Mask)) {
|
||||
unsigned V1Size = cast<VectorType>(V1->getType())->getNumElements();
|
||||
unsigned V1Size = cast<FixedVectorType>(V1->getType())->getNumElements();
|
||||
for (Value *Op : MV->operands()) {
|
||||
if (auto *CI = dyn_cast<ConstantInt>(Op)) {
|
||||
if (CI->uge(V1Size*2))
|
||||
@ -2010,8 +2010,9 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
|
||||
}
|
||||
|
||||
if (const auto *CDS = dyn_cast<ConstantDataSequential>(Mask)) {
|
||||
unsigned V1Size = cast<VectorType>(V1->getType())->getNumElements();
|
||||
for (unsigned i = 0, e = MaskTy->getNumElements(); i != e; ++i)
|
||||
unsigned V1Size = cast<FixedVectorType>(V1->getType())->getNumElements();
|
||||
for (unsigned i = 0, e = cast<FixedVectorType>(MaskTy)->getNumElements();
|
||||
i != e; ++i)
|
||||
if (CDS->getElementAsInteger(i) >= V1Size*2)
|
||||
return false;
|
||||
return true;
|
||||
@ -2022,12 +2023,26 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
|
||||
|
||||
void ShuffleVectorInst::getShuffleMask(const Constant *Mask,
|
||||
SmallVectorImpl<int> &Result) {
|
||||
unsigned NumElts = cast<VectorType>(Mask->getType())->getElementCount().Min;
|
||||
ElementCount EC = cast<VectorType>(Mask->getType())->getElementCount();
|
||||
|
||||
if (isa<ConstantAggregateZero>(Mask)) {
|
||||
Result.resize(NumElts, 0);
|
||||
Result.resize(EC.Min, 0);
|
||||
return;
|
||||
}
|
||||
Result.reserve(NumElts);
|
||||
|
||||
Result.reserve(EC.Min);
|
||||
|
||||
if (EC.Scalable) {
|
||||
assert((isa<ConstantAggregateZero>(Mask) || isa<UndefValue>(Mask)) &&
|
||||
"Scalable vector shuffle mask must be undef or zeroinitializer");
|
||||
int MaskVal = isa<UndefValue>(Mask) ? -1 : 0;
|
||||
for (unsigned I = 0; I < EC.Min; ++I)
|
||||
Result.emplace_back(MaskVal);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned NumElts = EC.Min;
|
||||
|
||||
if (auto *CDS = dyn_cast<ConstantDataSequential>(Mask)) {
|
||||
for (unsigned i = 0; i != NumElts; ++i)
|
||||
Result.push_back(CDS->getElementAsInteger(i));
|
||||
@ -2209,8 +2224,8 @@ bool ShuffleVectorInst::isExtractSubvectorMask(ArrayRef<int> Mask,
|
||||
bool ShuffleVectorInst::isIdentityWithPadding() const {
|
||||
if (isa<UndefValue>(Op<2>()))
|
||||
return false;
|
||||
int NumOpElts = cast<VectorType>(Op<0>()->getType())->getNumElements();
|
||||
int NumMaskElts = cast<VectorType>(getType())->getNumElements();
|
||||
int NumOpElts = cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
|
||||
int NumMaskElts = cast<FixedVectorType>(getType())->getNumElements();
|
||||
if (NumMaskElts <= NumOpElts)
|
||||
return false;
|
||||
|
||||
@ -2250,8 +2265,8 @@ bool ShuffleVectorInst::isConcat() const {
|
||||
isa<UndefValue>(Op<2>()))
|
||||
return false;
|
||||
|
||||
int NumOpElts = cast<VectorType>(Op<0>()->getType())->getNumElements();
|
||||
int NumMaskElts = getType()->getNumElements();
|
||||
int NumOpElts = cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
|
||||
int NumMaskElts = cast<FixedVectorType>(getType())->getNumElements();
|
||||
if (NumMaskElts != NumOpElts * 2)
|
||||
return false;
|
||||
|
||||
@ -2992,8 +3007,8 @@ CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
|
||||
"Invalid cast");
|
||||
assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
|
||||
assert((!Ty->isVectorTy() ||
|
||||
cast<VectorType>(Ty)->getNumElements() ==
|
||||
cast<VectorType>(S->getType())->getNumElements()) &&
|
||||
cast<FixedVectorType>(Ty)->getNumElements() ==
|
||||
cast<FixedVectorType>(S->getType())->getNumElements()) &&
|
||||
"Invalid cast");
|
||||
|
||||
if (Ty->isIntOrIntVectorTy())
|
||||
@ -3011,8 +3026,8 @@ CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
|
||||
"Invalid cast");
|
||||
assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
|
||||
assert((!Ty->isVectorTy() ||
|
||||
cast<VectorType>(Ty)->getNumElements() ==
|
||||
cast<VectorType>(S->getType())->getNumElements()) &&
|
||||
cast<FixedVectorType>(Ty)->getNumElements() ==
|
||||
cast<FixedVectorType>(S->getType())->getNumElements()) &&
|
||||
"Invalid cast");
|
||||
|
||||
if (Ty->isIntOrIntVectorTy())
|
||||
@ -3123,7 +3138,8 @@ bool CastInst::isCastable(Type *SrcTy, Type *DestTy) {
|
||||
|
||||
if (VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy))
|
||||
if (VectorType *DestVecTy = dyn_cast<VectorType>(DestTy))
|
||||
if (SrcVecTy->getNumElements() == DestVecTy->getNumElements()) {
|
||||
if (cast<FixedVectorType>(SrcVecTy)->getNumElements() ==
|
||||
cast<FixedVectorType>(DestVecTy)->getNumElements()) {
|
||||
// An element by element cast. Valid if casting the elements is valid.
|
||||
SrcTy = SrcVecTy->getElementType();
|
||||
DestTy = DestVecTy->getElementType();
|
||||
@ -3245,7 +3261,7 @@ CastInst::getCastOpcode(
|
||||
// FIXME: Check address space sizes here
|
||||
if (VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy))
|
||||
if (VectorType *DestVecTy = dyn_cast<VectorType>(DestTy))
|
||||
if (SrcVecTy->getNumElements() == DestVecTy->getNumElements()) {
|
||||
if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) {
|
||||
// An element by element cast. Find the appropriate opcode based on the
|
||||
// element types.
|
||||
SrcTy = SrcVecTy->getElementType();
|
||||
|
@ -2918,8 +2918,8 @@ void Verifier::visitAddrSpaceCastInst(AddrSpaceCastInst &I) {
|
||||
Assert(SrcTy->getPointerAddressSpace() != DestTy->getPointerAddressSpace(),
|
||||
"AddrSpaceCast must be between different address spaces", &I);
|
||||
if (auto *SrcVTy = dyn_cast<VectorType>(SrcTy))
|
||||
Assert(SrcVTy->getNumElements() ==
|
||||
cast<VectorType>(DestTy)->getNumElements(),
|
||||
Assert(cast<FixedVectorType>(SrcVTy)->getNumElements() ==
|
||||
cast<FixedVectorType>(DestTy)->getNumElements(),
|
||||
"AddrSpaceCast vector pointer number of elements mismatch", &I);
|
||||
visitInstruction(I);
|
||||
}
|
||||
@ -5061,7 +5061,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
|
||||
"Vector element type mismatch of the result and second operand "
|
||||
"vector!", IF);
|
||||
|
||||
Assert(ResultTy->getNumElements() ==
|
||||
Assert(cast<FixedVectorType>(ResultTy)->getNumElements() ==
|
||||
NumRows->getZExtValue() * NumColumns->getZExtValue(),
|
||||
"Result of a matrix operation does not fit in the returned vector!");
|
||||
|
||||
@ -5147,7 +5147,7 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
|
||||
Assert(Operand->getType()->isFPOrFPVectorTy(),
|
||||
"Intrinsic first argument must be floating point", &FPI);
|
||||
if (auto *OperandT = dyn_cast<VectorType>(Operand->getType())) {
|
||||
NumSrcElem = OperandT->getNumElements();
|
||||
NumSrcElem = cast<FixedVectorType>(OperandT)->getNumElements();
|
||||
}
|
||||
|
||||
Operand = &FPI;
|
||||
@ -5156,7 +5156,7 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
|
||||
Assert(Operand->getType()->isIntOrIntVectorTy(),
|
||||
"Intrinsic result must be an integer", &FPI);
|
||||
if (auto *OperandT = dyn_cast<VectorType>(Operand->getType())) {
|
||||
Assert(NumSrcElem == OperandT->getNumElements(),
|
||||
Assert(NumSrcElem == cast<FixedVectorType>(OperandT)->getNumElements(),
|
||||
"Intrinsic first argument and result vector lengths must be equal",
|
||||
&FPI);
|
||||
}
|
||||
@ -5170,7 +5170,7 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
|
||||
Assert(Operand->getType()->isIntOrIntVectorTy(),
|
||||
"Intrinsic first argument must be integer", &FPI);
|
||||
if (auto *OperandT = dyn_cast<VectorType>(Operand->getType())) {
|
||||
NumSrcElem = OperandT->getNumElements();
|
||||
NumSrcElem = cast<FixedVectorType>(OperandT)->getNumElements();
|
||||
}
|
||||
|
||||
Operand = &FPI;
|
||||
@ -5179,7 +5179,7 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
|
||||
Assert(Operand->getType()->isFPOrFPVectorTy(),
|
||||
"Intrinsic result must be a floating point", &FPI);
|
||||
if (auto *OperandT = dyn_cast<VectorType>(Operand->getType())) {
|
||||
Assert(NumSrcElem == OperandT->getNumElements(),
|
||||
Assert(NumSrcElem == cast<FixedVectorType>(OperandT)->getNumElements(),
|
||||
"Intrinsic first argument and result vector lengths must be equal",
|
||||
&FPI);
|
||||
}
|
||||
@ -5198,9 +5198,8 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
|
||||
Assert(OperandTy->isVectorTy() == ResultTy->isVectorTy(),
|
||||
"Intrinsic first argument and result disagree on vector use", &FPI);
|
||||
if (OperandTy->isVectorTy()) {
|
||||
auto *OperandVecTy = cast<VectorType>(OperandTy);
|
||||
auto *ResultVecTy = cast<VectorType>(ResultTy);
|
||||
Assert(OperandVecTy->getNumElements() == ResultVecTy->getNumElements(),
|
||||
Assert(cast<FixedVectorType>(OperandTy)->getNumElements() ==
|
||||
cast<FixedVectorType>(ResultTy)->getNumElements(),
|
||||
"Intrinsic first argument and result vector lengths must be equal",
|
||||
&FPI);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user