[PATCH] D69117: [gicombiner] Process the MatchDag such that every node is reachable from the roots

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 10:05:01 PDT 2019


dsanders marked an inline comment as done.
dsanders added inline comments.


================
Comment at: llvm/utils/TableGen/GICombinerEmitter.cpp:146
+  /// preparation work for flattening the DAG into a tree.
+  void reorientToRoots() {
+    SmallSet<const GIMatchDagInstr *, 5> Roots;
----------------
During an off-list review it was pointed out that this is quadratic in the worst case. I haven't fixed that yet but I don't think it's likely to be an issue in practice. This is partly due to the DAG's tending to be small (1-5 instr nodes) but is mostly due to the common case for the shape of the DAG.

The quadratic case is a 'straight-line' DAG of the form:
  A->B->C->D->E
which can occasionally occur but is rarely more than 3 nodes long. The best case is a fan-out like:
  A->{B,C,D,E}
which is linear but most DAGs will be roughly nlogn. For example:
  A->{B,C}
  B->{D,E}

If it becomes a bottleneck then I can improve this


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69117/new/

https://reviews.llvm.org/D69117





More information about the llvm-commits mailing list