[PATCH] D152033: TTI: Pass function to hasBranchDivergence in a few passes

Sameer Sahasrabuddhe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 3 05:34:03 PDT 2023


sameerds added inline comments.


================
Comment at: llvm/test/Transforms/SpeculativeExecution/single-lane-execution.ll:14
+; CHECK: a:
+; CHECK: %x = add i32 2, 3
+a:
----------------
arsenm wrote:
> sameerds wrote:
> > Shouldn't this have been moved to the entry block??
> No, the point is it wasn’t because it’s acting like a non divergent target.
> 
> The spec-exec-only-if-divergent-target flag doesn’t really make sense to me though
>From the pass implementation itself, it seems this pass was introduced specifically for "targets where branches are expensive", especially GPUs. But does this cost come from the branch instruction itself, or the EXEC masking that we have to do around divergent branches? If it is the former, then I am guessing it doesn't matter if only a single thread is running; the branch on a GPU is still expensive. If that is correct, then for this one optimization modelling a single thread as a "non-divergent target" is not useful, and we should always speculate if the raw target has divergence.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152033/new/

https://reviews.llvm.org/D152033



More information about the llvm-commits mailing list