Unreasonable branches

So, here is an example of unreasonable branch: llvm-project/reverse.h at 7949a2a802f0791eaf7c6ecbdd6ed5daa2a278cf · llvm/llvm-project · GitHub

What is stays for? We have the stronger check on the next line of code. Is it really because of some strange circle buffers? Why do we need to support this? Is std::reverse the best way to reverse something cyclic?

Unreasonable branches are quite bad, especially in multi-platform compilers.

This does not seem to be an LLVM optimization question, moving to libc++

(It may be interesting to file an optimization bug to llvm if it does not optimize the trivial redundant branch though)

The branch isn’t redundant. if __first == __last, --__last could result in UB.

1 Like

Oh, always look for the corner case. Thanks and sorry =)