mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-22 00:37:49 +00:00
Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask').
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27727 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
730b45694b
commit
706126dac1
@ -7046,8 +7046,6 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
|
||||
if (isa<UndefValue>(Mask))
|
||||
return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType()));
|
||||
|
||||
// TODO: Canonicalize shuffle(undef,x) -> shuffle(x, undef).
|
||||
|
||||
// TODO: If we have shuffle(x, undef, mask) and any elements of mask refer to
|
||||
// the undef, change them to undefs.
|
||||
|
||||
@ -7077,6 +7075,28 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
|
||||
MadeChange = true;
|
||||
}
|
||||
|
||||
// Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask').
|
||||
if (isa<UndefValue>(LHS)) {
|
||||
// shuffle(undef,x,<0,0,0,0>) -> undef.
|
||||
if (isa<ConstantAggregateZero>(Mask))
|
||||
return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType()));
|
||||
|
||||
ConstantPacked *CPM = cast<ConstantPacked>(Mask);
|
||||
std::vector<Constant*> Elts;
|
||||
for (unsigned i = 0, e = CPM->getNumOperands(); i != e; ++i) {
|
||||
if (isa<UndefValue>(CPM->getOperand(i)))
|
||||
Elts.push_back(CPM->getOperand(i));
|
||||
else {
|
||||
unsigned EltNo = cast<ConstantUInt>(CPM->getOperand(i))->getRawValue();
|
||||
if (EltNo >= e/2)
|
||||
Elts.push_back(ConstantUInt::get(Type::UIntTy, EltNo-e/2));
|
||||
else // Referring to the undef.
|
||||
Elts.push_back(UndefValue::get(Type::UIntTy));
|
||||
}
|
||||
}
|
||||
return new ShuffleVectorInst(RHS, LHS, ConstantPacked::get(Elts));
|
||||
}
|
||||
|
||||
if (ConstantPacked *CP = dyn_cast<ConstantPacked>(Mask)) {
|
||||
bool isLHSID = true, isRHSID = true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user