[llvm] 2107af9 - Revert "[VPlan] Add & use VPValue operands for VPWidenRecipe (NFC)."
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 23 22:10:18 PDT 2020
Author: Mehdi Amini
Date: 2020-04-24T05:07:32Z
New Revision: 2107af9ccfdfe67a90ea9ed4f3bfd7c72c4e29ac
URL: https://github.com/llvm/llvm-project/commit/2107af9ccfdfe67a90ea9ed4f3bfd7c72c4e29ac
DIFF: https://github.com/llvm/llvm-project/commit/2107af9ccfdfe67a90ea9ed4f3bfd7c72c4e29ac.diff
LOG: Revert "[VPlan] Add & use VPValue operands for VPWidenRecipe (NFC)."
This reverts commit 9245c7ac13480ed48ae339ad0e68cbe680cd0642.
This is triggering a segfault in XLA downstream, we'll follow-up with
a reproducer, it is likely influenced by TTI/TLI settings or other
options as a simple `opt -loop-vectorize` invocation on the IR
before the crash does not reproduce immediately.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6bb4380a499a..7cb1695d05b3 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -407,8 +407,7 @@ class InnerLoopVectorizer {
BasicBlock *createVectorizedLoopSkeleton();
/// Widen a single instruction within the innermost loop.
- void widenInstruction(Instruction &I, VPUser &Operands,
- VPTransformState &State);
+ void widenInstruction(Instruction &I);
/// Widen a single call instruction within the innermost loop.
void widenCallInstruction(CallInst &I, VPUser &ArgOperands,
@@ -4232,8 +4231,7 @@ static bool mayDivideByZero(Instruction &I) {
return !CInt || CInt->isZero();
}
-void InnerLoopVectorizer::widenInstruction(Instruction &I, VPUser &User,
- VPTransformState &State) {
+void InnerLoopVectorizer::widenInstruction(Instruction &I) {
switch (I.getOpcode()) {
case Instruction::Call:
case Instruction::Br:
@@ -4265,8 +4263,8 @@ void InnerLoopVectorizer::widenInstruction(Instruction &I, VPUser &User,
for (unsigned Part = 0; Part < UF; ++Part) {
SmallVector<Value *, 2> Ops;
- for (VPValue *VPOp : User.operands())
- Ops.push_back(State.get(VPOp, Part));
+ for (Value *Op : I.operands())
+ Ops.push_back(getOrCreateVectorValue(Op, Part));
Value *V = Builder.CreateNAryOp(I.getOpcode(), Ops);
@@ -4287,8 +4285,8 @@ void InnerLoopVectorizer::widenInstruction(Instruction &I, VPUser &User,
auto *Cmp = cast<CmpInst>(&I);
setDebugLocFromInst(Builder, Cmp);
for (unsigned Part = 0; Part < UF; ++Part) {
- Value *A = State.get(User.getOperand(0), Part);
- Value *B = State.get(User.getOperand(1), Part);
+ Value *A = getOrCreateVectorValue(Cmp->getOperand(0), Part);
+ Value *B = getOrCreateVectorValue(Cmp->getOperand(1), Part);
Value *C = nullptr;
if (FCmp) {
// Propagate fast math flags.
@@ -4325,7 +4323,7 @@ void InnerLoopVectorizer::widenInstruction(Instruction &I, VPUser &User,
(VF == 1) ? CI->getType() : VectorType::get(CI->getType(), VF);
for (unsigned Part = 0; Part < UF; ++Part) {
- Value *A = State.get(User.getOperand(0), Part);
+ Value *A = getOrCreateVectorValue(CI->getOperand(0), Part);
Value *Cast = Builder.CreateCast(CI->getOpcode(), A, DestTy);
VectorLoopValueMap.setVectorValue(&I, Part, Cast);
addMetadata(Cast, &I);
@@ -6938,7 +6936,12 @@ VPWidenCallRecipe *VPRecipeBuilder::tryToWidenCall(CallInst *CI, VFRange &Range,
if (!LoopVectorizationPlanner::getDecisionAndClampRange(willWiden, Range))
return nullptr;
- return new VPWidenCallRecipe(*CI, Plan.mapToVPValues(CI->arg_operands()));
+ // Success: widen this call.
+ auto VPValues = map_range(CI->arg_operands(), [&Plan](Value *Op) {
+ return Plan.getOrAddVPValue(Op);
+ });
+
+ return new VPWidenCallRecipe(*CI, VPValues);
}
bool VPRecipeBuilder::shouldWiden(Instruction *I, VFRange &Range) const {
@@ -7001,7 +7004,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VPlan &Plan) const {
return nullptr;
// Success: widen this instruction.
- return new VPWidenRecipe(*I, Plan.mapToVPValues(I->operands()));
+ return new VPWidenRecipe(*I);
}
VPBasicBlock *VPRecipeBuilder::handleReplication(
@@ -7408,7 +7411,7 @@ void VPWidenSelectRecipe::execute(VPTransformState &State) {
}
void VPWidenRecipe::execute(VPTransformState &State) {
- State.ILV->widenInstruction(Ingredient, User, State);
+ State.ILV->widenInstruction(Ingredient);
}
void VPWidenGEPRecipe::execute(VPTransformState &State) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index cd8c129a5bd7..25afb09129ff 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -767,13 +767,8 @@ class VPWidenRecipe : public VPRecipeBase {
/// Hold the instruction to be widened.
Instruction &Ingredient;
- /// Hold VPValues for the operands of the ingredient.
- VPUser User;
-
public:
- template <typename IterT>
- VPWidenRecipe(Instruction &I, iterator_range<IterT> Operands)
- : VPRecipeBase(VPWidenSC), Ingredient(I), User(Operands) {}
+ VPWidenRecipe(Instruction &I) : VPRecipeBase(VPWidenSC), Ingredient(I) {}
~VPWidenRecipe() override = default;
@@ -1623,16 +1618,6 @@ class VPlan {
/// Dump the plan to stderr (for debugging).
void dump() const;
- /// Returns a range mapping the values the range \p Operands to their
- /// corresponding VPValues.
- iterator_range<mapped_iterator<Use *, std::function<VPValue *(Value *)>>>
- mapToVPValues(User::op_range Operands) {
- std::function<VPValue *(Value *)> Fn = [this](Value *Op) {
- return getOrAddVPValue(Op);
- };
- return map_range(Operands, Fn);
- }
-
private:
/// Add to the given dominator tree the header block and every new basic block
/// that was created between it and the latch block, inclusive.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 2b48b2b59160..fa864889efa3 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -72,8 +72,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
NewRecipe = new VPWidenGEPRecipe(GEP, OrigLoop);
} else
- NewRecipe =
- new VPWidenRecipe(*Inst, Plan->mapToVPValues(Inst->operands()));
+ NewRecipe = new VPWidenRecipe(*Inst);
NewRecipe->insertBefore(Ingredient);
Ingredient->eraseFromParent();
More information about the llvm-commits
mailing list