Skip to content

Commit d9fb162

Browse files
committed
!fixup address latest comments, thanks
1 parent 980a2f7 commit d9fb162

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,8 +1031,6 @@ class VPInstructionWithType : public VPInstruction {
10311031
/// Scalar result type produced by the recipe.
10321032
Type *ResultTy;
10331033

1034-
Value *generate(VPTransformState &State);
1035-
10361034
public:
10371035
VPInstructionWithType(unsigned Opcode, ArrayRef<VPValue *> Operands,
10381036
Type *ResultTy, DebugLoc DL, const Twine &Name = "")
@@ -1048,16 +1046,16 @@ class VPInstructionWithType : public VPInstruction {
10481046
}
10491047

10501048
VPInstruction *clone() override {
1051-
auto *New =
1052-
new VPInstructionWithType(getOpcode(), {getOperand(0)}, getResultType(),
1053-
getDebugLoc(), getName());
1049+
SmallVector<VPValue *, 2> Operands(operands());
1050+
auto *New = new VPInstructionWithType(
1051+
getOpcode(), Operands, getResultType(), getDebugLoc(), getName());
10541052
New->setUnderlyingValue(getUnderlyingValue());
10551053
return New;
10561054
}
10571055

10581056
void execute(VPTransformState &State) override;
10591057

1060-
/// Return the cost of this VPIRInstruction.
1058+
/// Return the cost of this VPInstruction.
10611059
InstructionCost computeCost(ElementCount VF,
10621060
VPCostContext &Ctx) const override {
10631061
// TODO: Compute accurate cost after retiring the legacy cost model.

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
261261
VPPartialReductionRecipe>([this](const VPRecipeBase *R) {
262262
return inferScalarType(R->getOperand(0));
263263
})
264+
// VPInstructionWithType must be handled before VPInstruction.
264265
.Case<VPInstructionWithType, VPWidenIntrinsicRecipe>(
265266
[](const auto *R) { return R->getResultType(); })
266267
.Case<VPBlendRecipe, VPInstruction, VPWidenRecipe, VPReplicateRecipe,

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,28 +1069,24 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
10691069
}
10701070
#endif
10711071

1072-
Value *VPInstructionWithType::generate(VPTransformState &State) {
1072+
void VPInstructionWithType::execute(VPTransformState &State) {
10731073
State.setDebugLocFrom(getDebugLoc());
10741074
assert(vputils::onlyFirstLaneUsed(this) &&
10751075
"Codegen only implemented for first lane.");
10761076
switch (getOpcode()) {
1077-
case Instruction::SExt:
10781077
case Instruction::ZExt:
10791078
case Instruction::Trunc: {
1080-
// Note: SExt/ZExt not used yet.
10811079
Value *Op = State.get(getOperand(0), VPLane(0));
1082-
return State.Builder.CreateCast(Instruction::CastOps(getOpcode()), Op,
1083-
ResultTy);
1080+
Value *Cast = State.Builder.CreateCast(Instruction::CastOps(getOpcode()),
1081+
Op, ResultTy);
1082+
State.set(this, Cast, VPLane(0));
1083+
break;
10841084
}
10851085
default:
10861086
llvm_unreachable("opcode not implemented yet");
10871087
}
10881088
}
10891089

1090-
void VPInstructionWithType::execute(VPTransformState &State) {
1091-
State.set(this, generate(State), VPLane(0));
1092-
}
1093-
10941090
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
10951091
void VPInstructionWithType::print(raw_ostream &O, const Twine &Indent,
10961092
VPSlotTracker &SlotTracker) const {

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ bool vputils::isUniformAcrossVFsAndUFs(VPValue *V) {
112112
all_of(R->operands(), isUniformAcrossVFsAndUFs);
113113
})
114114
.Case<VPInstruction>([](const auto *VPI) {
115-
return Instruction::isCast(VPI->getOpcode())
116-
? all_of(VPI->operands(), isUniformAcrossVFsAndUFs)
117-
: false;
115+
return Instruction::isCast(VPI->getOpcode()) &&
116+
all_of(VPI->operands(), isUniformAcrossVFsAndUFs);
118117
})
119118
.Case<VPWidenCastRecipe>([](const auto *R) {
120119
// A cast is uniform according to its operand.

0 commit comments

Comments
 (0)