Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.466 -> 1.467 --- Log message: Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask'). --- Diffs of the changes: (+22 -2) InstructionCombining.cpp | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.466 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.467 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.466 Fri Apr 14 20:39:45 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sat Apr 15 19:03:56 2006 @@ -7046,8 +7046,6 @@ 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 @@ 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; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits