Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/include/llvm/CodeGen/SelectionDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <cstdint>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
Expand Down Expand Up @@ -247,6 +248,9 @@ class SelectionDAG {
BlockFrequencyInfo *BFI = nullptr;
MachineModuleInfo *MMI = nullptr;

/// Extended EVTs used for single value VTLists.
std::set<EVT, EVT::compareRawBits> EVTs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try all the set types? Does DenseSet do any better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try DenseSEt. Looks like we would need to add a DenseMapInfo for EVT including defining Empty and Tombstone values?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage here depends on the address stability of the map entries (the VTList points at the map's key), and DenseSet doesn't provide that. So you'd need define a struct like EVTSetKey Key { EVT* Ptr; };, define DenseMapInfo for that, then use DenseSet<EVTSetKey>.

I guess you could do that, but it seems like overkill.


/// List of non-single value types.
FoldingSet<SDVTListNode> VTListMap;

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/CodeGen/SelectionDAGNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ END_TWO_BYTE_PACK()
DebugLoc debugLoc;

/// Return a pointer to the specified value type.
static const EVT *getValueTypeList(EVT VT);
static const EVT *getValueTypeList(MVT VT);

/// Index in worklist of DAGCombiner, or negative if the node is not in the
/// worklist. -1 = not in worklist; -2 = not in worklist, but has already been
Expand Down Expand Up @@ -1124,7 +1124,7 @@ END_TWO_BYTE_PACK()
void addUse(SDUse &U) { U.addToList(&UseList); }

protected:
static SDVTList getSDVTList(EVT VT) {
static SDVTList getSDVTList(MVT VT) {
SDVTList Ret = { getValueTypeList(VT), 1 };
return Ret;
}
Expand Down
17 changes: 7 additions & 10 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10623,7 +10623,10 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
}

SDVTList SelectionDAG::getVTList(EVT VT) {
return makeVTList(SDNode::getValueTypeList(VT), 1);
if (!VT.isExtended())
return makeVTList(SDNode::getValueTypeList(VT.getSimpleVT()), 1);

return makeVTList(&(*EVTs.insert(VT).first), 1);
}

SDVTList SelectionDAG::getVTList(EVT VT1, EVT VT2) {
Expand Down Expand Up @@ -12383,17 +12386,11 @@ namespace {

/// getValueTypeList - Return a pointer to the specified value type.
///
const EVT *SDNode::getValueTypeList(EVT VT) {
static std::set<EVT, EVT::compareRawBits> EVTs;
const EVT *SDNode::getValueTypeList(MVT VT) {
static EVTArray SimpleVTArray;
static sys::SmartMutex<true> VTMutex;

if (VT.isExtended()) {
sys::SmartScopedLock<true> Lock(VTMutex);
return &(*EVTs.insert(VT).first);
}
assert(VT.getSimpleVT() < MVT::VALUETYPE_SIZE && "Value type out of range!");
return &SimpleVTArray.VTs[VT.getSimpleVT().SimpleTy];
assert(VT < MVT::VALUETYPE_SIZE && "Value type out of range!");
return &SimpleVTArray.VTs[VT.SimpleTy];
}

/// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
Expand Down
Loading