iree icon indicating copy to clipboard operation
iree copied to clipboard

[Util] Rework SimplifyGlobalAccesses to use DFX and support SCF

Open qedawkins opened this issue 2 years ago • 2 comments

This reimplements SimplifyGlobalAccesses using DFX to analyze the way different operations access globals, and then performs similar movement of global accessors (loads move up the CFG and stores move down) based on the analysis result. This adds proper tracking for nested regions and some support for invariant accessor hoisting from loop-like ops based on upstream interfaces.

NYI are

  1. Motion through CF/branch based control flow. A slightly different addition to the analysis is probably needed to track when it is legal to hoist through a conditional branch, but this is currently assuming it will be easier/more common to handle earlier on at the SCF level.
  2. Hoisting through function boundaries. Currently the propagation doesn't properly track accesses by functions after the initial analysis, but as noted in a comment this doesn't affect the outcome of any of the current patterns.
  3. Hoisting out of scf.if/scf.while. Ifs are just NYI and require slightly different handling, and whiles are missing the interface function we use for scf.for to do the hoisting.

qedawkins avatar Dec 26 '23 06:12 qedawkins

probably worth a quick sync - RE indirect: we don't really support them today anywhere else and disable optimizations in their presence, so that's fine to do here

benvanik avatar Jan 23 '24 21:01 benvanik

Abbreviated Benchmark Summary

@ commit 97a6dd50268e9b2c8e916e0d885dca3869bc03eb (vs. base 9dfc61288c13389a1e52a5f934387783d10ce65b)

No improved or regressed compilation metrics 🏖️

For more information:

Source Workflow Run

github-actions[bot] avatar Mar 02 '24 06:03 github-actions[bot]