It's something we saw in highschool, I would expect anyone with a CS degree to recognize this optimization.
I barely know anything about compiler optimization, so I have no clue whether a compiler applying this optimization is surprising or something trivial.
Implementing this in a compiler is nontrivial.