mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Move some code from Verifier into SVI::isValidOperands. This allows us to catch bad shufflevector operations when they are created, rather than waiting for someone to notice later on.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110986 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ca2835411f
commit
a966af2f4c
@ -1430,9 +1430,24 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
|
||||
return false;
|
||||
|
||||
const VectorType *MaskTy = dyn_cast<VectorType>(Mask->getType());
|
||||
if (!isa<Constant>(Mask) || MaskTy == 0 ||
|
||||
!MaskTy->getElementType()->isIntegerTy(32))
|
||||
if (MaskTy == 0 || !MaskTy->getElementType()->isIntegerTy(32))
|
||||
return false;
|
||||
|
||||
// Check to see if Mask is valid.
|
||||
if (const ConstantVector *MV = dyn_cast<ConstantVector>(Mask)) {
|
||||
const VectorType *VTy = cast<VectorType>(V1->getType());
|
||||
for (unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) {
|
||||
if (ConstantInt* CI = dyn_cast<ConstantInt>(MV->getOperand(i))) {
|
||||
if (CI->uge(VTy->getNumElements()*2))
|
||||
return false;
|
||||
} else if (!isa<UndefValue>(MV->getOperand(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!isa<UndefValue>(Mask) && !isa<ConstantAggregateZero>(Mask))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1322,27 +1322,6 @@ void Verifier::visitShuffleVectorInst(ShuffleVectorInst &SV) {
|
||||
Assert1(ShuffleVectorInst::isValidOperands(SV.getOperand(0), SV.getOperand(1),
|
||||
SV.getOperand(2)),
|
||||
"Invalid shufflevector operands!", &SV);
|
||||
|
||||
const VectorType *VTy = dyn_cast<VectorType>(SV.getOperand(0)->getType());
|
||||
Assert1(VTy, "Operands are not a vector type", &SV);
|
||||
|
||||
// Check to see if Mask is valid.
|
||||
if (const ConstantVector *MV = dyn_cast<ConstantVector>(SV.getOperand(2))) {
|
||||
for (unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) {
|
||||
if (ConstantInt* CI = dyn_cast<ConstantInt>(MV->getOperand(i))) {
|
||||
Assert1(!CI->uge(VTy->getNumElements()*2),
|
||||
"Invalid shufflevector shuffle mask!", &SV);
|
||||
} else {
|
||||
Assert1(isa<UndefValue>(MV->getOperand(i)),
|
||||
"Invalid shufflevector shuffle mask!", &SV);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Assert1(isa<UndefValue>(SV.getOperand(2)) ||
|
||||
isa<ConstantAggregateZero>(SV.getOperand(2)),
|
||||
"Invalid shufflevector shuffle mask!", &SV);
|
||||
}
|
||||
|
||||
visitInstruction(SV);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user