Skip to content

Commit d6b9b42

Browse files
committed
[VPlan] Combine LiveIns fields into MapVector (NFC)
Combine Value2VPValue and VPLiveIns into a single MapVector LiveIns field, simplifying users.
1 parent 3ca85e7 commit d6b9b42

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define LLVM_TRANSFORMS_VECTORIZE_VPLAN_H
2626

2727
#include "VPlanValue.h"
28-
#include "llvm/ADT/DenseMap.h"
28+
#include "llvm/ADT/MapVector.h"
2929
#include "llvm/ADT/SmallPtrSet.h"
3030
#include "llvm/ADT/SmallVector.h"
3131
#include "llvm/ADT/Twine.h"
@@ -4332,13 +4332,9 @@ class VPlan {
43324332
/// Represents the loop-invariant VF * UF of the vector loop region.
43334333
VPValue VFxUF;
43344334

4335-
/// Holds a mapping between Values and their corresponding VPValue inside
4336-
/// VPlan.
4337-
Value2VPValueTy Value2VPValue;
4338-
4339-
/// Contains all the external definitions created for this VPlan. External
4340-
/// definitions are VPValues that hold a pointer to their underlying IR.
4341-
SmallVector<VPValue *, 16> VPLiveIns;
4335+
/// Contains all the external definitions created for this VPlan, as a mapping
4336+
/// from IR Values to VPValues.
4337+
SmallMapVector<Value *, VPValue *, 16> LiveIns;
43424338

43434339
/// Blocks allocated and owned by the VPlan. They will be deleted once the
43444340
/// VPlan is destroyed.
@@ -4535,10 +4531,9 @@ class VPlan {
45354531
/// yet) for \p V.
45364532
VPValue *getOrAddLiveIn(Value *V) {
45374533
assert(V && "Trying to get or add the VPValue of a null Value");
4538-
auto [It, Inserted] = Value2VPValue.try_emplace(V);
4534+
auto [It, Inserted] = LiveIns.try_emplace(V);
45394535
if (Inserted) {
45404536
VPValue *VPV = new VPValue(V);
4541-
VPLiveIns.push_back(VPV);
45424537
assert(VPV->isLiveIn() && "VPV must be a live-in.");
45434538
It->second = VPV;
45444539
}
@@ -4570,17 +4565,10 @@ class VPlan {
45704565
}
45714566

45724567
/// Return the live-in VPValue for \p V, if there is one or nullptr otherwise.
4573-
VPValue *getLiveIn(Value *V) const { return Value2VPValue.lookup(V); }
4568+
VPValue *getLiveIn(Value *V) const { return LiveIns.lookup(V); }
45744569

45754570
/// Return the list of live-in VPValues available in the VPlan.
4576-
ArrayRef<VPValue *> getLiveIns() const {
4577-
assert(all_of(Value2VPValue,
4578-
[this](const auto &P) {
4579-
return is_contained(VPLiveIns, P.second);
4580-
}) &&
4581-
"all VPValues in Value2VPValue must also be in VPLiveIns");
4582-
return VPLiveIns;
4583-
}
4571+
auto getLiveIns() const { return LiveIns.values(); }
45844572

45854573
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
45864574
/// Print the live-ins of this VPlan to \p O.

llvm/lib/Transforms/Vectorize/VPlanValue.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_VALUE_H
2121
#define LLVM_TRANSFORMS_VECTORIZE_VPLAN_VALUE_H
2222

23-
#include "llvm/ADT/DenseMap.h"
2423
#include "llvm/ADT/STLExtras.h"
2524
#include "llvm/ADT/SmallVector.h"
26-
#include "llvm/ADT/StringMap.h"
2725
#include "llvm/ADT/TinyPtrVector.h"
2826
#include "llvm/ADT/iterator_range.h"
2927
#include "llvm/Support/Compiler.h"
@@ -196,9 +194,6 @@ class LLVM_ABI_FOR_TEST VPValue {
196194
}
197195
};
198196

199-
typedef DenseMap<Value *, VPValue *> Value2VPValueTy;
200-
typedef DenseMap<VPValue *, Value *> VPValue2ValueTy;
201-
202197
LLVM_ABI_FOR_TEST raw_ostream &operator<<(raw_ostream &OS,
203198
const VPRecipeBase &R);
204199

0 commit comments

Comments
 (0)