[all-commits] [llvm/llvm-project] 7b08b4: [SPIR-V] add convergence region analysis (#78456)

Nathan Gauër via All-commits all-commits at lists.llvm.org
Fri Feb 2 09:22:26 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7b08b4360b488b35428c97132b3f9d2a777bd770
      https://github.com/llvm/llvm-project/commit/7b08b4360b488b35428c97132b3f9d2a777bd770
  Author: Nathan Gauër <brioche at google.com>
  Date:   2024-02-02 (Fri, 02 Feb 2024)

  Changed paths:
    A llvm/lib/Target/SPIRV/Analysis/CMakeLists.txt
    A llvm/lib/Target/SPIRV/Analysis/SPIRVConvergenceRegionAnalysis.cpp
    A llvm/lib/Target/SPIRV/Analysis/SPIRVConvergenceRegionAnalysis.h
    M llvm/lib/Target/SPIRV/CMakeLists.txt
    M llvm/lib/Target/SPIRV/SPIRV.h
    M llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
    A llvm/unittests/Target/SPIRV/CMakeLists.txt
    A llvm/unittests/Target/SPIRV/SPIRVConvergenceRegionAnalysisTests.cpp

  Log Message:
  -----------
  [SPIR-V] add convergence region analysis (#78456)

This new analysis returns a hierarchical view of the convergence regions
in the given function.
This will allow our passes to query which basic block belongs to which
convergence region, and structurize the code in consequence.

Definition
----------

A convergence region is a CFG with:
 - a single entry node.
 - one or multiple exit nodes (different from LLVM's regions).
 - one back-edge
 - zero or more subregions.

Excluding sub-regions nodes, the nodes of a region can only reference a
single convergence token. A subregion uses a different convergence
token.

Algorithm
---------

This algorithm assumes all loops are in the Simplify form.

Create an initial convergence region for the whole function.
  - the convergence token is the function entry token.
  - the entry is the function entrypoint.
- Exits are all the basic blocks terminating with a return instruction.

Take the function CFG, and process it in DAG order (ignoring
back-edges). If a basic block is a loop header:
 - Create a new region.
- The parent region is the parent's loop region if any, otherwise, the
top level region.
   - The region blocks are all the blocks belonging to this loop.
- For each loop exit: - visit the rest of the CFG in DAG order (ignore
back-edges). - if the region's convergence token is found, add all the
blocks dominated by the exit from which the token is reachable to the
region.
   - continue the algorithm with the loop headers successors.




More information about the All-commits mailing list