forked from OSchip/llvm-project
Fix an expensive-checks error.
The Mask and LHSMask may not be of the same size, so don't do the transformation if they're different. llvm-svn: 88972
This commit is contained in:
parent
c2ef215bda
commit
a3ce7828b2
|
@ -12917,29 +12917,33 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
|
||||||
if (isa<UndefValue>(RHS)) {
|
if (isa<UndefValue>(RHS)) {
|
||||||
std::vector<unsigned> LHSMask = getShuffleMask(LHSSVI);
|
std::vector<unsigned> LHSMask = getShuffleMask(LHSSVI);
|
||||||
|
|
||||||
std::vector<unsigned> NewMask;
|
if (LHSMask.size() == Mask.size()) {
|
||||||
for (unsigned i = 0, e = Mask.size(); i != e; ++i)
|
std::vector<unsigned> NewMask;
|
||||||
if (Mask[i] >= 2*e)
|
for (unsigned i = 0, e = Mask.size(); i != e; ++i)
|
||||||
NewMask.push_back(2*e);
|
if (Mask[i] >= 2*e)
|
||||||
else
|
NewMask.push_back(2*e);
|
||||||
NewMask.push_back(LHSMask[Mask[i]]);
|
else
|
||||||
|
NewMask.push_back(LHSMask[Mask[i]]);
|
||||||
|
|
||||||
// If the result mask is equal to the src shuffle or this shuffle mask, do
|
// If the result mask is equal to the src shuffle or this
|
||||||
// the replacement.
|
// shuffle mask, do the replacement.
|
||||||
if (NewMask == LHSMask || NewMask == Mask) {
|
if (NewMask == LHSMask || NewMask == Mask) {
|
||||||
unsigned LHSInNElts =
|
unsigned LHSInNElts =
|
||||||
cast<VectorType>(LHSSVI->getOperand(0)->getType())->getNumElements();
|
cast<VectorType>(LHSSVI->getOperand(0)->getType())->
|
||||||
std::vector<Constant*> Elts;
|
getNumElements();
|
||||||
for (unsigned i = 0, e = NewMask.size(); i != e; ++i) {
|
std::vector<Constant*> Elts;
|
||||||
if (NewMask[i] >= LHSInNElts*2) {
|
for (unsigned i = 0, e = NewMask.size(); i != e; ++i) {
|
||||||
Elts.push_back(UndefValue::get(Type::getInt32Ty(*Context)));
|
if (NewMask[i] >= LHSInNElts*2) {
|
||||||
} else {
|
Elts.push_back(UndefValue::get(Type::getInt32Ty(*Context)));
|
||||||
Elts.push_back(ConstantInt::get(Type::getInt32Ty(*Context), NewMask[i]));
|
} else {
|
||||||
|
Elts.push_back(ConstantInt::get(Type::getInt32Ty(*Context),
|
||||||
|
NewMask[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return new ShuffleVectorInst(LHSSVI->getOperand(0),
|
||||||
|
LHSSVI->getOperand(1),
|
||||||
|
ConstantVector::get(Elts));
|
||||||
}
|
}
|
||||||
return new ShuffleVectorInst(LHSSVI->getOperand(0),
|
|
||||||
LHSSVI->getOperand(1),
|
|
||||||
ConstantVector::get(Elts));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue