src/codegen.cpp: add CSE pass right before loop unswitching.

This doesn't cause loop unswitching to kick in but it does produce
cleaner code in some cases. The CSE pass could probably be placed
elsewhere but this spot seems to work well enough.
ByteVec: use a single `if` for bounds check and error raising.