[llvm] [GVNSink] Fix non-determinisms by using Depth-First ordering (PR #90995)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon May 6 11:35:32 PDT 2024


efriedma-quic wrote:

> > SplitBlockPredecessors invalidates the DFS numbering, I think.
> 
> Makes sense to just update DFSNumbes with each split block.

updateDFSNumbers walks the whole function, so that's quadratic in the size of the function.  If you don't care about the exact numbers, maybe consider just building your own numbering as you visit PHI nodes.  It's only a few lines to construct a `DenseMap<BasicBlock*, int>`.

> > Also, SplitBlockPredecessors changes the predecessor list of a basic block, which I think needs to invalidate any ModelledPHI referring to that block?
> 
> AFAICT all the ModelledPHI are created for a specific SinkBB (in SinkBB and analyzeInstructionForSinking functions) and then destroyed.

So the numbers don't need to be stable across blocks?  That makes things simpler.

https://github.com/llvm/llvm-project/pull/90995


More information about the llvm-commits mailing list