Skip to content

Commit e7547f6

Browse files
committed
fix the comments
1 parent 4a43c98 commit e7547f6

File tree

5 files changed

+31
-42
lines changed

5 files changed

+31
-42
lines changed

llvm/include/llvm/IR/VectorBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ class VectorBuilder {
9999
const Twine &Name = Twine());
100100

101101
/// Emit a VP reduction intrinsic call for recurrence kind.
102-
/// \param ID The intrinsic ID of call Intrinsic
102+
/// \param RdxID The intrinsic ID of llvm.vector.reduce.*
103103
/// \param ValTy The type of operand which the reduction operation is
104104
/// performed.
105105
/// \param VecOpArray The operand list.
106-
Value *createSimpleIntrinsic(Intrinsic::ID ID, Type *ValTy,
106+
Value *createSimpleReduction(Intrinsic::ID RdxID, Type *ValTy,
107107
ArrayRef<Value *> VecOpArray,
108108
const Twine &Name = Twine());
109109
};

llvm/lib/IR/VectorBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ Value *VectorBuilder::createVectorInstruction(unsigned Opcode, Type *ReturnTy,
6060
return createVectorInstructionImpl(VPID, ReturnTy, InstOpArray, Name);
6161
}
6262

63-
Value *VectorBuilder::createSimpleIntrinsic(Intrinsic::ID ID, Type *ValTy,
63+
Value *VectorBuilder::createSimpleReduction(Intrinsic::ID RdxID, Type *ValTy,
6464
ArrayRef<Value *> InstOpArray,
6565
const Twine &Name) {
66-
auto VPID = VPIntrinsic::getForIntrinsic(ID);
67-
assert(VPIntrinsic::isVPIntrinsic(VPID) &&
68-
"No VPIntrinsic for this Intrinsic");
66+
auto VPID = VPIntrinsic::getForIntrinsic(RdxID);
67+
assert(VPReductionIntrinsic::isVPReduction(VPID) &&
68+
"No VPIntrinsic for this reduction");
6969
return createVectorInstructionImpl(VPID, ValTy, InstOpArray, Name);
7070
}
7171

llvm/lib/Transforms/Utils/LoopUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ Value *llvm::createSimpleReduction(VectorBuilder &VBuilder, Value *Src,
13001300
Type *SrcEltTy = SrcTy->getElementType();
13011301
Value *Iden = getRecurrenceIdentity(Kind, SrcEltTy, Desc.getFastMathFlags());
13021302
Value *Ops[] = {Iden, Src};
1303-
return VBuilder.createSimpleIntrinsic(Id, SrcTy, Ops);
1303+
return VBuilder.createSimpleReduction(Id, SrcTy, Ops);
13041304
}
13051305

13061306
Value *llvm::createReduction(IRBuilderBase &B,
@@ -1343,7 +1343,7 @@ Value *llvm::createOrderedReduction(VectorBuilder &VBuilder,
13431343
Intrinsic::ID Id = getReductionIntrinsicID(RecurKind::FAdd);
13441344
auto *SrcTy = cast<VectorType>(Src->getType());
13451345
Value *Ops[] = {Start, Src};
1346-
return VBuilder.createSimpleIntrinsic(Id, SrcTy, Ops);
1346+
return VBuilder.createSimpleReduction(Id, SrcTy, Ops);
13471347
}
13481348

13491349
void llvm::propagateIRFlags(Value *I, ArrayRef<Value *> VL, Value *OpValue,

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -994,39 +994,33 @@ void VPWidenIntrinsicRecipe::execute(VPTransformState &State) {
994994
Args.push_back(Arg);
995995
}
996996

997-
if (VPIntrinsic::isVPIntrinsic(VectorIntrinsicID)) {
998-
// Use vector version of the vector predicate Intrinsic
999-
IRBuilderBase &BuilderIR = State.Builder;
1000-
VectorBuilder VBuilder(BuilderIR);
1001-
Value *Mask = BuilderIR.CreateVectorSplat(State.VF, BuilderIR.getTrue());
1002-
VBuilder.setMask(Mask).setEVL(Args.back());
1003-
// Remove the EVL from Args
997+
if (VPIntrinsic::isVPIntrinsic(VectorIntrinsicID) &&
998+
VectorIntrinsicID != Intrinsic::vp_select) {
999+
Value *Mask =
1000+
State.Builder.CreateVectorSplat(State.VF, State.Builder.getTrue());
1001+
Value *EVL = Args.back();
10041002
Args.pop_back();
1005-
Value *VPInst = VBuilder.createSimpleIntrinsic(
1006-
VectorIntrinsicID, TysForDecl[0], Args, "vp.call");
1007-
if (!VPInst->getType()->isVoidTy())
1008-
State.set(this, VPInst);
1009-
State.addMetadata(VPInst,
1010-
dyn_cast_or_null<Instruction>(getUnderlyingValue()));
1011-
} else {
1012-
// Use vector version of the intrinsic.
1013-
Module *M = State.Builder.GetInsertBlock()->getModule();
1014-
Function *VectorF =
1015-
Intrinsic::getOrInsertDeclaration(M, VectorIntrinsicID, TysForDecl);
1016-
assert(VectorF && "Can't retrieve vector intrinsic.");
1003+
Args.push_back(Mask);
1004+
Args.push_back(EVL);
1005+
}
10171006

1018-
auto *CI = cast_or_null<CallInst>(getUnderlyingValue());
1019-
SmallVector<OperandBundleDef, 1> OpBundles;
1020-
if (CI)
1021-
CI->getOperandBundlesAsDefs(OpBundles);
1007+
// Use vector version of the intrinsic.
1008+
Module *M = State.Builder.GetInsertBlock()->getModule();
1009+
Function *VectorF =
1010+
Intrinsic::getOrInsertDeclaration(M, VectorIntrinsicID, TysForDecl);
1011+
assert(VectorF && "Can't retrieve vector intrinsic.");
10221012

1023-
CallInst *V = State.Builder.CreateCall(VectorF, Args, OpBundles);
1024-
setFlags(V);
1013+
auto *CI = cast_or_null<CallInst>(getUnderlyingValue());
1014+
SmallVector<OperandBundleDef, 1> OpBundles;
1015+
if (CI)
1016+
CI->getOperandBundlesAsDefs(OpBundles);
10251017

1026-
if (!V->getType()->isVoidTy())
1027-
State.set(this, V);
1028-
State.addMetadata(V, CI);
1029-
}
1018+
CallInst *V = State.Builder.CreateCall(VectorF, Args, OpBundles);
1019+
setFlags(V);
1020+
1021+
if (!V->getType()->isVoidTy())
1022+
State.set(this, V);
1023+
State.addMetadata(V, CI);
10301024
}
10311025

10321026
InstructionCost VPWidenIntrinsicRecipe::computeCost(ElementCount VF,

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,14 +1493,9 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
14931493
CI->getCalledFunction()->getIntrinsicID());
14941494
if (VPID == Intrinsic::not_intrinsic)
14951495
return nullptr;
1496-
// FIXME: In fact, can we really not pass the
1497-
// underlyingInstr? In this case, how to set the Flag and
1498-
// add metadata in execute?
14991496
return new VPWidenIntrinsicRecipe(
15001497
VPID, Ops, TypeInfo.inferScalarType(CInst), false,
15011498
false, false);
1502-
// return new VPWidenIntrinsicRecipe(
1503-
// *CI, VPID, Ops, CI->getType(), CI->getDebugLoc());
15041499
})
15051500
.Case<VPWidenSelectRecipe>([&](VPWidenSelectRecipe *Sel) {
15061501
SmallVector<VPValue *> Ops(Sel->operands());

0 commit comments

Comments
 (0)