This is an archive of the discontinued LLVM Phabricator instance.

[Review Request] Numbering SDNode to discard SmallPtrSet in selection DAG
Needs ReviewPublic

Authored by shawfly on Jul 12 2013, 1:29 AM.

Details

Reviewers
resistor
Summary

In selection DAG, SmallPtrSet is widely used to indicate the existence of SDNode in a set when traversing the DAG. This consumes 3~5% of total compilation time. SmallPtrSet is a good data structure, but it is not suitable here; by numbering the SDNode, it can be done in O(1) to indicate whether a SDNode is visited or not.

Each SDNode belongs to a Selection DAG, in this patch, SDNode is numbered according to its belonged Selection DAG. This patch could improve llc performance by 2.5-3% for SpecCPU2006.

Diff Detail

Event Timeline

Some high level comments:

  • SmallPtrSet is usually O(1) but falls back to linear search when it's small. SmallPtrSet<64> is way too large, have you benchmarked with the small capacity lowered to 8 or 16? This of course adds malloc overhead in more cases but we might get away with it.

If the above fails:

  • I really don't see the point of FlagVector. Why not just use a SmallVector (or SmallBitVector as we're only storing bools) and resize appropriately when it's used. In any case, the class does not belong in SmallVector.h.

Thanks for your review.

  1. SmallBitVector can meet what FlagVector can after some minor changes, but for the convenience of review, I don't want to change it since it is a common container which is used by most people, I will change to use SmallBitVector instead of FlagVector.
  1. SmallBitVector is usually O(1), but the overhead to construct this set is hot, the insert_impl is very hot.

[cid:image001.png@01CE7F3B.A70406A0]

  • {F9266, layout=link}
resistor edited edge metadata.Feb 15 2015, 4:28 PM
resistor set the repository for this revision to rL LLVM.
mehdi_amini added inline comments.
include/llvm/CodeGen/SelectionDAGNodes.h
964

Minor comment if you update this revision: variable should start with an uppercase: s/ownerDAG/OwnerDAG/

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
900

Why 1? I would have expected 0 here?

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
549

No need for else here after continue.