|
25 | 25 | #define LLVM_TRANSFORMS_VECTORIZE_VPLAN_H |
26 | 26 |
|
27 | 27 | #include "VPlanValue.h" |
28 | | -#include "llvm/ADT/DenseMap.h" |
| 28 | +#include "llvm/ADT/MapVector.h" |
29 | 29 | #include "llvm/ADT/SmallPtrSet.h" |
30 | 30 | #include "llvm/ADT/SmallVector.h" |
31 | 31 | #include "llvm/ADT/Twine.h" |
@@ -4332,13 +4332,9 @@ class VPlan { |
4332 | 4332 | /// Represents the loop-invariant VF * UF of the vector loop region. |
4333 | 4333 | VPValue VFxUF; |
4334 | 4334 |
|
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; |
4342 | 4338 |
|
4343 | 4339 | /// Blocks allocated and owned by the VPlan. They will be deleted once the |
4344 | 4340 | /// VPlan is destroyed. |
@@ -4535,10 +4531,9 @@ class VPlan { |
4535 | 4531 | /// yet) for \p V. |
4536 | 4532 | VPValue *getOrAddLiveIn(Value *V) { |
4537 | 4533 | 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); |
4539 | 4535 | if (Inserted) { |
4540 | 4536 | VPValue *VPV = new VPValue(V); |
4541 | | - VPLiveIns.push_back(VPV); |
4542 | 4537 | assert(VPV->isLiveIn() && "VPV must be a live-in."); |
4543 | 4538 | It->second = VPV; |
4544 | 4539 | } |
@@ -4570,17 +4565,10 @@ class VPlan { |
4570 | 4565 | } |
4571 | 4566 |
|
4572 | 4567 | /// 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); } |
4574 | 4569 |
|
4575 | 4570 | /// 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(); } |
4584 | 4572 |
|
4585 | 4573 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
4586 | 4574 | /// Print the live-ins of this VPlan to \p O. |
|
0 commit comments