mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Allow vectorization of intrinsics such as powi,cttz and ctlz in Loop and SLP Vectorizer.
This patch adds support to vectorize intrinsics such as powi, cttz and ctlz in Vectorizer. These intrinsics are different from other intrinsics as second argument to these function must be same in order to vectorize them and it should be represented as a scalar. Review: http://reviews.llvm.org/D3851#inline-32769 and http://reviews.llvm.org/D3937#inline-32857 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209873 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -3123,9 +3123,14 @@ void InnerLoopVectorizer::vectorizeBlockInLoop(BasicBlock *BB, PhiVector *PV) {
|
||||
scalarizeInstruction(it);
|
||||
break;
|
||||
default:
|
||||
bool HasScalarOpd = hasVectorInstrinsicScalarOpd(ID, 1);
|
||||
for (unsigned Part = 0; Part < UF; ++Part) {
|
||||
SmallVector<Value *, 4> Args;
|
||||
for (unsigned i = 0, ie = CI->getNumArgOperands(); i != ie; ++i) {
|
||||
if (HasScalarOpd && i == 1) {
|
||||
Args.push_back(CI->getArgOperand(i));
|
||||
continue;
|
||||
}
|
||||
VectorParts &Arg = getVectorValue(CI->getArgOperand(i));
|
||||
Args.push_back(Arg[Part]);
|
||||
}
|
||||
@@ -3474,6 +3479,16 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Intrinsics such as powi,cttz and ctlz are legal to vectorize if the
|
||||
// second argument is the same (i.e. loop invariant)
|
||||
if (CI &&
|
||||
hasVectorInstrinsicScalarOpd(getIntrinsicIDForCall(CI, TLI), 1)) {
|
||||
if (!SE->isLoopInvariant(SE->getSCEV(CI->getOperand(1)), TheLoop)) {
|
||||
DEBUG(dbgs() << "LV: Found unvectorizable intrinsic " << *CI << "\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the instruction return type is vectorizable.
|
||||
// Also, we can't vectorize extractelement instructions.
|
||||
if ((!VectorType::isValidElementType(it->getType()) &&
|
||||
|
Reference in New Issue
Block a user