[llvm] Optimize circular buffers (PR #75722)

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 10:18:21 PST 2023


felipepiovezan wrote:

I don't think the compiler performs the optimization is either case:
https://godbolt.org/z/xqeY8zaE6

FWIW unsigned overflow is defined behavior, so `x +1 == end` will do the _wrong_ thing if `x` is unsigned and `x+1` overflows and the type of `end` is something larger like uint64_t. 

The same situation when `x` is `int` is undefined behavior and would be caught by tooling.

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


More information about the llvm-commits mailing list