Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4,173 Lines • ▼ Show 20 Lines | void InnerLoopVectorizer::widenCallInstruction(CallInst &CI, VPValue *Def, | ||||
InstructionCost IntrinsicCost = | InstructionCost IntrinsicCost = | ||||
ID ? Cost->getVectorIntrinsicCost(&CI, VF) : 0; | ID ? Cost->getVectorIntrinsicCost(&CI, VF) : 0; | ||||
bool UseVectorIntrinsic = ID && IntrinsicCost <= CallCost; | bool UseVectorIntrinsic = ID && IntrinsicCost <= CallCost; | ||||
assert((UseVectorIntrinsic || !NeedToScalarize) && | assert((UseVectorIntrinsic || !NeedToScalarize) && | ||||
"Instruction should be scalarized elsewhere."); | "Instruction should be scalarized elsewhere."); | ||||
assert((IntrinsicCost.isValid() || CallCost.isValid()) && | assert((IntrinsicCost.isValid() || CallCost.isValid()) && | ||||
"Either the intrinsic cost or vector call cost must be valid"); | "Either the intrinsic cost or vector call cost must be valid"); | ||||
bool UseReturnOverloadType = isVectorIntrinsicWithReturnOverloadType(ID); | |||||
for (unsigned Part = 0; Part < UF; ++Part) { | for (unsigned Part = 0; Part < UF; ++Part) { | ||||
SmallVector<Type *, 2> TysForDecl = {CI.getType()}; | SmallVector<Type *, 2> TysForDecl; | ||||
if (UseReturnOverloadType) | |||||
eopXD: I guess you will need the same change under `VPlanRecipes::widenPredicateCallHelper` too? | |||||
TysForDecl.push_back(CI.getType()); | |||||
SmallVector<Value *, 4> Args; | SmallVector<Value *, 4> Args; | ||||
for (const auto &I : enumerate(ArgOperands.operands())) { | for (const auto &I : enumerate(ArgOperands.operands())) { | ||||
// Some intrinsics have a scalar argument - don't replace it with a | // Some intrinsics have a scalar argument - don't replace it with a | ||||
// vector. | // vector. | ||||
Value *Arg; | Value *Arg; | ||||
if (!UseVectorIntrinsic || | if (!UseVectorIntrinsic || | ||||
!isVectorIntrinsicWithScalarOpAtArg(ID, I.index())) | !isVectorIntrinsicWithScalarOpAtArg(ID, I.index())) | ||||
Arg = State.get(I.value(), Part); | Arg = State.get(I.value(), Part); | ||||
else | else | ||||
Arg = State.get(I.value(), VPIteration(0, 0)); | Arg = State.get(I.value(), VPIteration(0, 0)); | ||||
if (isVectorIntrinsicWithOverloadTypeAtArg(ID, I.index())) | if (isVectorIntrinsicWithOverloadTypeAtArg(ID, I.index())) | ||||
TysForDecl.push_back(Arg->getType()); | TysForDecl.push_back(Arg->getType()); | ||||
Args.push_back(Arg); | Args.push_back(Arg); | ||||
} | } | ||||
Function *VectorF; | Function *VectorF; | ||||
if (UseVectorIntrinsic) { | if (UseVectorIntrinsic) { | ||||
// Use vector version of the intrinsic. | // Use vector version of the intrinsic. | ||||
if (VF.isVector()) | if (UseReturnOverloadType && VF.isVector()) | ||||
TysForDecl[0] = VectorType::get(CI.getType()->getScalarType(), VF); | TysForDecl[0] = VectorType::get(CI.getType()->getScalarType(), VF); | ||||
Module *M = State.Builder.GetInsertBlock()->getModule(); | Module *M = State.Builder.GetInsertBlock()->getModule(); | ||||
VectorF = Intrinsic::getDeclaration(M, ID, TysForDecl); | VectorF = Intrinsic::getDeclaration(M, ID, TysForDecl); | ||||
assert(VectorF && "Can't retrieve vector intrinsic."); | assert(VectorF && "Can't retrieve vector intrinsic."); | ||||
} else { | } else { | ||||
// Use vector version of the function call. | // Use vector version of the function call. | ||||
const VFShape Shape = VFShape::get(CI, VF, false /*HasGlobalPred*/); | const VFShape Shape = VFShape::get(CI, VF, false /*HasGlobalPred*/); | ||||
#ifndef NDEBUG | #ifndef NDEBUG | ||||
▲ Show 20 Lines • Show All 6,413 Lines • Show Last 20 Lines |
I guess you will need the same change under VPlanRecipes::widenPredicateCallHelper too?