Skip to content

Commit

Permalink
[DAGCombine] Replace std::monostate equivalent in DAGCombiner.cpp
Browse files Browse the repository at this point in the history
Remove the `UnitT` type and operators in favor of using `std::monostate`
directly.

Differential Revision: https://reviews.llvm.org/D131778
  • Loading branch information
JoeLoser committed Aug 13, 2022
1 parent bca8895 commit b12aa49
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Expand Up @@ -72,6 +72,7 @@
#include <string>
#include <tuple>
#include <utility>
#include <variant>

using namespace llvm;

Expand Down Expand Up @@ -24943,13 +24944,6 @@ SDValue DAGCombiner::FindBetterChain(SDNode *N, SDValue OldChain) {
return DAG.getTokenFactor(SDLoc(N), Aliases);
}

namespace {
// TODO: Replace with with std::monostate when we move to C++17.
struct UnitT { } Unit;
bool operator==(const UnitT &, const UnitT &) { return true; }
bool operator!=(const UnitT &, const UnitT &) { return false; }
} // namespace

// This function tries to collect a bunch of potentially interesting
// nodes to improve the chains of, all at once. This might seem
// redundant, as this function gets called when visiting every store
Expand All @@ -24970,8 +24964,8 @@ bool DAGCombiner::parallelizeChainedStores(StoreSDNode *St) {
// the common case, every store writes to the immediately previous address
// space and thus merged with the previous interval at insertion time.

using IMap =
llvm::IntervalMap<int64_t, UnitT, 8, IntervalMapHalfOpenInfo<int64_t>>;
using IMap = llvm::IntervalMap<int64_t, std::monostate, 8,
IntervalMapHalfOpenInfo<int64_t>>;
IMap::Allocator A;
IMap Intervals(A);

Expand All @@ -24998,7 +24992,8 @@ bool DAGCombiner::parallelizeChainedStores(StoreSDNode *St) {
return false;

// Add ST's interval.
Intervals.insert(0, (St->getMemoryVT().getSizeInBits() + 7) / 8, Unit);
Intervals.insert(0, (St->getMemoryVT().getSizeInBits() + 7) / 8,
std::monostate{});

while (StoreSDNode *Chain = dyn_cast<StoreSDNode>(STChain->getChain())) {
if (Chain->getMemoryVT().isScalableVector())
Expand Down Expand Up @@ -25027,7 +25022,7 @@ bool DAGCombiner::parallelizeChainedStores(StoreSDNode *St) {
// If there's a previous interval, we should start after it.
if (I != Intervals.begin() && (--I).stop() <= Offset)
break;
Intervals.insert(Offset, Offset + Length, Unit);
Intervals.insert(Offset, Offset + Length, std::monostate{});

ChainedStores.push_back(Chain);
STChain = Chain;
Expand Down

0 comments on commit b12aa49

Please sign in to comment.