[PATCH] D25343: [OpenCL] Mark group functions as noduplicate in opencl-c.h

Tom Stellard via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 08:38:41 PDT 2016


tstellarAMD added a comment.

In https://reviews.llvm.org/D25343#565288, @Anastasia wrote:

> Do you have any code example where Clang/LLVM performs wrong optimizations with respect to the control flow of SPMD execution?
>
> My understanding from the earlier discussion we have had: https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that noduplicate is essentially enough for the frontend to prevent erroneous optimizations. Because in general compiler can't do much with unknown function calls.


noduplicate is enough for correctness, but it prevents legal optimizations, like unrolling loops with barriers.  The convergent attribute was added specifically for these kinds of builtins, so we should be using it here instead of noduplicate.

> For LLVM intrinsics it is slightly different as I can deduce from this discussion:http://lists.llvm.org/pipermail/llvm-dev/2015-May/085558.html . It seems like by default it's assumed to be side effect free and can be optimized in various ways.




https://reviews.llvm.org/D25343





More information about the cfe-commits mailing list