Skip to content

Commit 243fc6f

Browse files
committed
!fixup address latest comments, thanks
1 parent 7d2ab86 commit 243fc6f

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
@@ -1030,8 +1030,6 @@ class VPInstructionWithType : public VPInstruction {
10301030
/// Scalar result type produced by the recipe.
10311031
Type *ResultTy;
10321032

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

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

10571055
void execute(VPTransformState &State) override;
10581056

1059-
/// Return the cost of this VPIRInstruction.
1057+
/// Return the cost of this VPInstruction.
10601058
InstructionCost computeCost(ElementCount VF,
10611059
VPCostContext &Ctx) const override {
10621060
// 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
@@ -259,6 +259,7 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
259259
VPPartialReductionRecipe>([this](const VPRecipeBase *R) {
260260
return inferScalarType(R->getOperand(0));
261261
})
262+
// VPInstructionWithType must be handled before VPInstruction.
262263
.Case<VPInstructionWithType, VPWidenIntrinsicRecipe>(
263264
[](const auto *R) { return R->getResultType(); })
264265
.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
@@ -1039,28 +1039,24 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
10391039
}
10401040
#endif
10411041

1042-
Value *VPInstructionWithType::generate(VPTransformState &State) {
1042+
void VPInstructionWithType::execute(VPTransformState &State) {
10431043
State.setDebugLocFrom(getDebugLoc());
10441044
assert(vputils::onlyFirstLaneUsed(this) &&
10451045
"Codegen only implemented for first lane.");
10461046
switch (getOpcode()) {
1047-
case Instruction::SExt:
10481047
case Instruction::ZExt:
10491048
case Instruction::Trunc: {
1050-
// Note: SExt/ZExt not used yet.
10511049
Value *Op = State.get(getOperand(0), VPLane(0));
1052-
return State.Builder.CreateCast(Instruction::CastOps(getOpcode()), Op,
1053-
ResultTy);
1050+
Value *Cast = State.Builder.CreateCast(Instruction::CastOps(getOpcode()),
1051+
Op, ResultTy);
1052+
State.set(this, Cast, VPLane(0));
1053+
break;
10541054
}
10551055
default:
10561056
llvm_unreachable("opcode not implemented yet");
10571057
}
10581058
}
10591059

1060-
void VPInstructionWithType::execute(VPTransformState &State) {
1061-
State.set(this, generate(State), VPLane(0));
1062-
}
1063-
10641060
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
10651061
void VPInstructionWithType::print(raw_ostream &O, const Twine &Indent,
10661062
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)