SROA: Generate selects instead of shuffles when blending values because this is the cannonical form.

Shuffles are more difficult to lower and we usually don't touch them, while we do optimize selects more often.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180875 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nadav Rotem
2013-05-01 19:53:30 +00:00
parent f0b0755b6e
commit fee6969463
2 changed files with 20 additions and 22 deletions

View File

@ -2322,17 +2322,15 @@ static Value *insertVector(IRBuilderTy &IRB, Value *Old, Value *V,
V = IRB.CreateShuffleVector(V, UndefValue::get(V->getType()),
ConstantVector::get(Mask),
Name + ".expand");
DEBUG(dbgs() << " shuffle1: " << *V << "\n");
DEBUG(dbgs() << " shuffle: " << *V << "\n");
Mask.clear();
for (unsigned i = 0; i != VecTy->getNumElements(); ++i)
if (i >= BeginIndex && i < EndIndex)
Mask.push_back(IRB.getInt32(i));
else
Mask.push_back(IRB.getInt32(i + VecTy->getNumElements()));
V = IRB.CreateShuffleVector(V, Old, ConstantVector::get(Mask),
Name + "insert");
DEBUG(dbgs() << " shuffle2: " << *V << "\n");
Mask.push_back(IRB.getInt1(i >= BeginIndex && i < EndIndex));
V = IRB.CreateSelect(ConstantVector::get(Mask), V, Old, Name + "blend");
DEBUG(dbgs() << " blend: " << *V << "\n");
return V;
}