|
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" |
@@ -4325,13 +4325,9 @@ class VPlan { |
4325 | 4325 | /// Represents the loop-invariant VF * UF of the vector loop region. |
4326 | 4326 | VPValue VFxUF; |
4327 | 4327 |
|
4328 | | - /// Holds a mapping between Values and their corresponding VPValue inside |
4329 | | - /// VPlan. |
4330 | | - Value2VPValueTy Value2VPValue; |
4331 | | - |
4332 | | - /// Contains all the external definitions created for this VPlan. External |
4333 | | - /// definitions are VPValues that hold a pointer to their underlying IR. |
4334 | | - SmallVector<VPValue *, 16> VPLiveIns; |
| 4328 | + /// Contains all the external definitions created for this VPlan, as a mapping |
| 4329 | + /// from IR Values to VPValues. |
| 4330 | + SmallMapVector<Value *, VPValue *, 16> LiveIns; |
4335 | 4331 |
|
4336 | 4332 | /// Blocks allocated and owned by the VPlan. They will be deleted once the |
4337 | 4333 | /// VPlan is destroyed. |
@@ -4528,10 +4524,9 @@ class VPlan { |
4528 | 4524 | /// yet) for \p V. |
4529 | 4525 | VPValue *getOrAddLiveIn(Value *V) { |
4530 | 4526 | assert(V && "Trying to get or add the VPValue of a null Value"); |
4531 | | - auto [It, Inserted] = Value2VPValue.try_emplace(V); |
| 4527 | + auto [It, Inserted] = LiveIns.try_emplace(V); |
4532 | 4528 | if (Inserted) { |
4533 | 4529 | VPValue *VPV = new VPValue(V); |
4534 | | - VPLiveIns.push_back(VPV); |
4535 | 4530 | assert(VPV->isLiveIn() && "VPV must be a live-in."); |
4536 | 4531 | It->second = VPV; |
4537 | 4532 | } |
@@ -4563,17 +4558,10 @@ class VPlan { |
4563 | 4558 | } |
4564 | 4559 |
|
4565 | 4560 | /// Return the live-in VPValue for \p V, if there is one or nullptr otherwise. |
4566 | | - VPValue *getLiveIn(Value *V) const { return Value2VPValue.lookup(V); } |
| 4561 | + VPValue *getLiveIn(Value *V) const { return LiveIns.lookup(V); } |
4567 | 4562 |
|
4568 | 4563 | /// Return the list of live-in VPValues available in the VPlan. |
4569 | | - ArrayRef<VPValue *> getLiveIns() const { |
4570 | | - assert(all_of(Value2VPValue, |
4571 | | - [this](const auto &P) { |
4572 | | - return is_contained(VPLiveIns, P.second); |
4573 | | - }) && |
4574 | | - "all VPValues in Value2VPValue must also be in VPLiveIns"); |
4575 | | - return VPLiveIns; |
4576 | | - } |
| 4564 | + auto getLiveIns() const { return LiveIns.values(); } |
4577 | 4565 |
|
4578 | 4566 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
4579 | 4567 | /// Print the live-ins of this VPlan to \p O. |
|
0 commit comments