[llvm] [NVPTX] Handle unreachable default in llvm::SwitchIns. (PR #72641)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 14:48:13 PST 2024


mmoadeli wrote:

> Comparing the PTX in your reproducer I do not see any interesting differences. All the code gets optimized exactly the same way, down to exactly the same number of registers, so the diff is _very_ clean. The exit is not blocking any optimizations and the difference is literally one extra predicated branch to `exit` at the end of a function.
> 
> I think compiler does exactly what it should be doing and that this particular issue must be handled at the user source code level. If some switch values are truly impossible, it should be made explicit in the source code and that should allow compiler to optimize that extra jump away. Previously the code had apparently relied on UB that resulted in a cost-free fall-through through the unreachable part. If the fall-through is intentional, or impossible and we expect compiler to do something specific, the user code should be explicit about that. We should not be restoring any particular kind of undefined behavior we may have done in the past.

I agree the there is not much difference between the two ptx. However, it is claimed that it made ethminer -3% performance regression on A100 CUDA. Moreover, to the best of my understanding of the code, there is nothing to be done at source level to address this issue.

https://github.com/llvm/llvm-project/pull/72641


More information about the llvm-commits mailing list