nhaehnle added a comment.

In D124158#3486110 <https://reviews.llvm.org/D124158#3486110>, @jdoerfert wrote:

> I agree. As far as I can tell you have two options, both are specific to the 
> shuffle functions:
>
> 1. Do not set noundef for calls to them as they allow undef values for all 
> lanes we don't read the value.
> 2. Freeze the inputs unconditionally.

Right, with some nitpicks. Option #1 is semantically more accurate: 
__shfl_sync, subgroupShuffe, and all similar instructions across GPU 
programming languages are meant to be conceptually similar to `select` in that 
they select a value from a lane. The "data" argument and return value should 
allow undef and poison. The incoming value is simply returned as-is, and so 
poison is propagated instead of causing immediate UB, just as it is for a 
`select` instruction. However, the lane argument can (and arguably should) 
still be `noundef`.

There's a separate curious issue in that apparently, reading from an 
uninitialized variable is **not** UB in CUDA/HIP/GLSL/HLSL/etc. If it was, a 
lot of code existing out there in the wild would be broken. But that's a matter 
for the relevant language standards to decide (for the subset of languages that 
//have// proper standards to begin with).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to