[PATCH] D50433: A New Divergence Analysis for LLVM

Simon Moll via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 8 03:43:59 PDT 2018


simoll created this revision.
Herald added subscribers: llvm-commits, jfb, dexonsmith, rogfer01, bollu, mgorny, nhaehnle, arsenm, jholewinski.

This revision implements the new DivergenceAnalysis for GPU kernels and loop vectorization presented in our RFC [1]. We provide it here as a point of reference. This revision breaks down into the following patches.

[1] llvm-dev "[RFC] A New Divergence Analysis for LLVM" (https://lists.llvm.org/pipermail/llvm-dev/2018-May/123606.html)

Patches
-------

1. [NFC] Rename the DivergenceAnalysis to KernelDivergenceAnalysis
------------------------------------------------------------------

The purpose of this is to free up the name DivergenceAnalysis for a new generic
implementation.  The generic implementation will be shared by specialized
divergence analysis classes.

2. [DA] DivergenceAnalysis for unstructured CFGs
------------------------------------------------

This patch contains a generic divergence analysis implementation for
unstructured, reducible Control-Flow Graphs. It contains two new classes.
The SyncDependenceAnalysis class lazily computes sync dependences, which
relate divergent branches to points of joining divergent control. The
DivergenceAnalysis class contains the generic divergence analysis
implementation.

3. [DA] LoopDivergenceAnalysis for loop vectorization
-----------------------------------------------------

The LoopDivergenceAnalysis is designed to be used by VPlan to decide
whether vectorization is worthwhile even before a VPlan is constructed.
This patch includes a LoopDivergencePrinter for testing.

4. [DA] GPUDivergenceAnalysis for unstructured GPU kernels
----------------------------------------------------------

The GPUDivergenceAnalysis is intended to eventually supersede the existing
KernelDivergenceAnalysis. The existing KernelDivergenceAnalysis produces
incorrect results on unstructured Control-Flow Graphs:

  <https://bugs.llvm.org/show_bug.cgi?id=37185>

This patch adds the option -use-gpu-da to the KernelDivergenceAnalysis
to turn it into a transparent wrapper for the GPUDivergenceAnalysis.

Contributions (req patches)
---------------------------

SyncDependenceAnalysis - sync dependence analysis for unstructured, reducible CFGs with divergent loops (#2)
DivergenceAnalysis - generic divergence analysis implementation (#1, #2)
GPUDivergenceAnalysis - GPU kernel front-end (#1, #2 and #4)
LoopDivergenceAnalysis - front-end for (outer) loop vectorization as a test bed for VPlan (#1, #2 and #3)


Repository:
  rL LLVM

https://reviews.llvm.org/D50433

Files:
  include/llvm/ADT/PostOrderIterator.h
  include/llvm/Analysis/DivergenceAnalysis.h
  include/llvm/Analysis/KernelDivergenceAnalysis.h
  include/llvm/Analysis/Passes.h
  include/llvm/Analysis/SyncDependenceAnalysis.h
  include/llvm/Analysis/TargetTransformInfo.h
  include/llvm/CodeGen/SelectionDAG.h
  include/llvm/CodeGen/TargetLowering.h
  include/llvm/InitializePasses.h
  include/llvm/LinkAllPasses.h
  lib/Analysis/Analysis.cpp
  lib/Analysis/CMakeLists.txt
  lib/Analysis/DivergenceAnalysis.cpp
  lib/Analysis/KernelDivergenceAnalysis.cpp
  lib/Analysis/SyncDependenceAnalysis.cpp
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
  lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
  lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
  lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
  lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
  lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
  lib/Target/AMDGPU/SIISelLowering.cpp
  lib/Target/AMDGPU/SIISelLowering.h
  lib/Transforms/Scalar/LoopUnswitch.cpp
  lib/Transforms/Scalar/StructurizeCFG.cpp
  test/Analysis/DivergenceAnalysis/AMDGPU/always_uniform.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/atomics.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/hidden_diverge.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/hidden_loopdiverge.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/intrinsics.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/kernel-args.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/llvm.amdgcn.buffer.atomic.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/llvm.amdgcn.image.atomic.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/no-return-blocks.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/phi-undef.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/unreachable-loop-block.ll
  test/Analysis/DivergenceAnalysis/AMDGPU/workitem-intrinsics.ll
  test/Analysis/DivergenceAnalysis/Loops/IndirectUniAccess.ll
  test/Analysis/DivergenceAnalysis/Loops/LoopWithDivBranch.ll
  test/Analysis/DivergenceAnalysis/Loops/LoopWithDivLoop.ll
  test/Analysis/DivergenceAnalysis/Loops/LoopWithLI.ll
  test/Analysis/DivergenceAnalysis/Loops/LoopWithUniBranch.ll
  test/Analysis/DivergenceAnalysis/Loops/LoopWithUniLoop.ll
  test/Analysis/DivergenceAnalysis/Loops/NonAffineUniLoop.ll
  test/Analysis/DivergenceAnalysis/Loops/SingleBlockLoop.ll
  test/Analysis/DivergenceAnalysis/NVPTX/daorder.ll
  test/Analysis/DivergenceAnalysis/NVPTX/diverge.ll
  test/Analysis/DivergenceAnalysis/NVPTX/hidden_diverge.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/atomics.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/intrinsics.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/kernel-args.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/lit.local.cfg
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/llvm.amdgcn.buffer.atomic.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/llvm.amdgcn.image.atomic.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/no-return-blocks.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/phi-undef.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/unreachable-loop-block.ll
  test/Analysis/KernelDivergenceAnalysis/AMDGPU/workitem-intrinsics.ll
  test/Analysis/KernelDivergenceAnalysis/NVPTX/diverge.ll
  test/Analysis/KernelDivergenceAnalysis/NVPTX/lit.local.cfg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50433.159668.patch
Type: text/x-patch
Size: 135839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180808/c5a611be/attachment.bin>


More information about the llvm-commits mailing list