Compiler writers do tend to assume programmers are inefficient so, if they are going to the trouble of optimising for some idiom, they'll probably put in the effort to detect and optimise variants of...