[PATCH] D91767: [DomTree][NFC] Introduce function that finds common dom of multiple instructions

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 22 21:36:12 PST 2020


mkazantsev added a comment.

In D91767#2408334 <https://reviews.llvm.org/D91767#2408334>, @kuhar wrote:

> As an alternative implementation, have you considered teaching `DomTree::findNCD` to work with multiple basic blocks first, and then using this to implement the multi-instruction `findNCD`?
> The algorithm would be like this: create a vector `VBB` of BB of all instructions, find its NCD, case split on the NCD and `VBB` being the same block or not.

I was considering that, but don't really see how it's useful. The existing code makes `N` iterations, for which of them it either calls `comesBefore` or `findNCD` (`findNCD` will be called as many times as many different blocks there is - 1).

In the proposed solution, I'll need to:

- FIll the set of blocks (because API of findNCD needs blocks)
- Call multi-arg findNCD (which will call two-arg NCD same amount of times)
- make comesBefore queries for all instructions in topmost block.

Effectively it's always the same number of findNCD queries, overhead on set creation and potentially less number of comesBefore queries (in my solution we do it in all blocks). So overhead on set filling doesn't seem worth saving some number of cheap comesBefore queries in general case. So I just don't see why this alternative solution is better.


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

https://reviews.llvm.org/D91767



More information about the llvm-commits mailing list