mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[VPlan] Add getVPSingleValue helper.
As suggested in D99294, this adds a getVPSingleValue helper to use for recipes that are guaranteed to define a single value. This replaces uses of getVPValue() which used to default to I = 0.
This commit is contained in:
parent
c91415a58a
commit
29eeedec33
@ -8498,7 +8498,7 @@ VPValue *VPRecipeBuilder::createBlockInMask(BasicBlock *BB, VPlanPtr &Plan) {
|
||||
else {
|
||||
auto IVRecipe = new VPWidenCanonicalIVRecipe();
|
||||
Builder.getInsertBlock()->insert(IVRecipe, NewInsertionPoint);
|
||||
IV = IVRecipe->getVPValue();
|
||||
IV = IVRecipe->getVPSingleValue();
|
||||
}
|
||||
VPValue *BTC = Plan->getOrCreateBackedgeTakenCount();
|
||||
bool TailFolded = !CM.isScalarEpilogueAllowed();
|
||||
@ -9215,11 +9215,11 @@ void LoopVectorizationPlanner::adjustRecipesForInLoopReductions(
|
||||
: nullptr;
|
||||
VPReductionRecipe *RedRecipe = new VPReductionRecipe(
|
||||
&RdxDesc, R, ChainOp, VecOp, CondOp, TTI);
|
||||
WidenRecipe->getVPValue()->replaceAllUsesWith(RedRecipe);
|
||||
WidenRecipe->getVPSingleValue()->replaceAllUsesWith(RedRecipe);
|
||||
Plan->removeVPValueFor(R);
|
||||
Plan->addVPValue(R, RedRecipe);
|
||||
WidenRecipe->getParent()->insert(RedRecipe, WidenRecipe->getIterator());
|
||||
WidenRecipe->getVPValue()->replaceAllUsesWith(RedRecipe);
|
||||
WidenRecipe->getVPSingleValue()->replaceAllUsesWith(RedRecipe);
|
||||
WidenRecipe->eraseFromParent();
|
||||
|
||||
if (RecurrenceDescriptor::isMinMaxRecurrenceKind(Kind)) {
|
||||
@ -9479,9 +9479,9 @@ void VPPredInstPHIRecipe::execute(VPTransformState &State) {
|
||||
|
||||
void VPWidenMemoryInstructionRecipe::execute(VPTransformState &State) {
|
||||
VPValue *StoredValue = isStore() ? getStoredValue() : nullptr;
|
||||
State.ILV->vectorizeMemoryInstruction(&Ingredient, State,
|
||||
StoredValue ? nullptr : getVPValue(),
|
||||
getAddr(), StoredValue, getMask());
|
||||
State.ILV->vectorizeMemoryInstruction(
|
||||
&Ingredient, State, StoredValue ? nullptr : getVPSingleValue(), getAddr(),
|
||||
StoredValue, getMask());
|
||||
}
|
||||
|
||||
// Determine how to lower the scalar epilogue, which depends on 1) optimising
|
||||
|
@ -1144,7 +1144,7 @@ void VPWidenCanonicalIVRecipe::execute(VPTransformState &State) {
|
||||
VF.isScalar() ? Indices.back() : ConstantVector::get(Indices);
|
||||
// Add the consecutive indices to the vector value.
|
||||
Value *CanonicalVectorIV = Builder.CreateAdd(VStart, VStep, "vec.iv");
|
||||
State.set(getVPValue(), CanonicalVectorIV, Part);
|
||||
State.set(getVPSingleValue(), CanonicalVectorIV, Part);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -671,10 +671,10 @@ public:
|
||||
/// Returns the underlying instruction, if the recipe is a VPValue or nullptr
|
||||
/// otherwise.
|
||||
Instruction *getUnderlyingInstr() {
|
||||
return cast<Instruction>(getVPValue()->getUnderlyingValue());
|
||||
return cast<Instruction>(getVPSingleValue()->getUnderlyingValue());
|
||||
}
|
||||
const Instruction *getUnderlyingInstr() const {
|
||||
return cast<Instruction>(getVPValue()->getUnderlyingValue());
|
||||
return cast<Instruction>(getVPSingleValue()->getUnderlyingValue());
|
||||
}
|
||||
|
||||
/// Method to support type inquiry through isa, cast, and dyn_cast.
|
||||
@ -738,7 +738,7 @@ public:
|
||||
: VPRecipeBase(VPRecipeBase::VPInstructionSC, {}),
|
||||
VPValue(VPValue::VPVInstructionSC, nullptr, this), Opcode(Opcode) {
|
||||
for (auto *I : Operands)
|
||||
addOperand(I->getVPValue());
|
||||
addOperand(I->getVPSingleValue());
|
||||
}
|
||||
|
||||
VPInstruction(unsigned Opcode, std::initializer_list<VPValue *> Operands)
|
||||
|
@ -33,7 +33,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
|
||||
// Introduce each ingredient into VPlan.
|
||||
for (auto I = VPBB->begin(), E = VPBB->end(); I != E;) {
|
||||
VPRecipeBase *Ingredient = &*I++;
|
||||
VPValue *VPV = Ingredient->getVPValue();
|
||||
VPValue *VPV = Ingredient->getVPSingleValue();
|
||||
Instruction *Inst = cast<Instruction>(VPV->getUnderlyingValue());
|
||||
if (DeadInstructions.count(Inst)) {
|
||||
VPValue DummyValue;
|
||||
@ -87,7 +87,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
|
||||
|
||||
NewRecipe->insertBefore(Ingredient);
|
||||
if (NewRecipe->getNumDefinedValues() == 1)
|
||||
VPV->replaceAllUsesWith(NewRecipe->getVPValue());
|
||||
VPV->replaceAllUsesWith(NewRecipe->getVPSingleValue());
|
||||
else
|
||||
assert(NewRecipe->getNumDefinedValues() == 0 &&
|
||||
"Only recpies with zero or one defined values expected");
|
||||
|
@ -328,8 +328,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the only VPValue defined by the VPDef. Can only be called for
|
||||
/// VPDefs with a single defined value.
|
||||
VPValue *getVPSingleValue() {
|
||||
assert(DefinedValues.size() == 1 && "must have exactly one defined value");
|
||||
assert(DefinedValues[0] && "defined value must be non-null");
|
||||
return DefinedValues[0];
|
||||
}
|
||||
const VPValue *getVPSingleValue() const {
|
||||
assert(DefinedValues.size() == 1 && "must have exactly one defined value");
|
||||
assert(DefinedValues[0] && "defined value must be non-null");
|
||||
return DefinedValues[0];
|
||||
}
|
||||
|
||||
/// Returns the VPValue with index \p I defined by the VPDef.
|
||||
VPValue *getVPValue(unsigned I = 0) {
|
||||
VPValue *getVPValue(unsigned I) {
|
||||
assert(DefinedValues[I] && "defined value must be non-null");
|
||||
return DefinedValues[I];
|
||||
}
|
||||
|
@ -942,7 +942,7 @@ TEST(VPRecipeTest, CastVPWidenMemoryInstructionRecipeToVPUserAndVPDef) {
|
||||
EXPECT_TRUE(isa<VPUser>(BaseR));
|
||||
EXPECT_EQ(&Recipe, BaseR);
|
||||
|
||||
VPValue *VPV = Recipe.getVPValue();
|
||||
VPValue *VPV = Recipe.getVPSingleValue();
|
||||
EXPECT_TRUE(isa<VPRecipeBase>(VPV->getDef()));
|
||||
EXPECT_EQ(&Recipe, dyn_cast<VPRecipeBase>(VPV->getDef()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user