LLVM Machine Instruction: Convergent attribute
ref: http://lists.llvm.org/pipermail/llvm-dev/2015-August/089241.html 1. Convergent attribute is useful for SIMT/SPMD programming model. 2. Intended interpretation is that a convergent operation cannot be move either into or out of a conditionally executed region. 3. If you have a convergent instruction A, it islegal to duplicate it to instruction B if (assuming B is after A in program flow) A dominates B and B post-dominates A. case: r1 = texture2D(..., r0, ...) if (...) { // r0 used as temporary here r0 = ... r2 = r0 + ... } else { // only use of r1 r2 = r1 + ... } In this example, various optimizations might try to sink the texture2D operation into the else block, like so: if (...) { r0 = ... r2 = r0 + ... } else { r1 = texture2D(..., r0, ...) r2 = r1 + ... } In most SPMD/SIMT implementations, the fallout of this races is exposed via the predicated expression of acyclic control flow: pred0 <- cmp ... if (pred0) r0 = ... ...