[PATCH] D50433: A New Divergence Analysis for LLVM

Simon Moll via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 8 07:04:25 PDT 2018


simoll added inline comments.


================
Comment at: lib/Analysis/SyncDependenceAnalysis.cpp:85-95
+//            entry
+//          /      \
+//         A        \
+//       /   \       Y
+// x0 = 0   x1 = 1  /
+//       \   /   \ /
+//      x2=phi    E
----------------
dnsampaio wrote:
> NIC: As to be more precise, you could put a origin value x in block  Y or before, and a phi=(x1, x) in block E.
> 
> I was wondering, if using some value numbering (GVN alike) or scev, if one could detect cases where x0 and x1 would hold the same value/expression. In such case, x2 would not be divergent isn't it? Perhaps is not something very common, although it happened in some old NVIDIA Cuda-sdk examples.
I think this is a misunderstanding. 

In the SyncDependenceAnalysis, we reduce the problem of finding sync dependencies to something which is very similar to SSA construction.
Sync dependences relate divergent branches to points of converging control, regardless of the actual values that are flowing.
The variable "x" and its assignments "x = 0" and "x = 1" do not really exist in the IR. We rather pretend they existed and run SSA construction to identify the would-be PHI nodes. The parent blocks of those nodes are reachable from disjoint paths from the divergent branch.

Now, what you are referring to is handled in the DivergenceAnalysis class (see `DivergenceAnalysis::updatePHINodes`). That's when there is a real PHINode with equivalent incoming values (or undef). This is shown, for example, in the `DivergenceAnalysis/AMDGPU/phi-undef.ll` test.


Repository:
  rL LLVM

https://reviews.llvm.org/D50433





More information about the llvm-commits mailing list