These expressions are lowered differently because `test2` gets a temporary due to the conditional reassignment of `u`, whereas `test1` is just a straight line switch and jump (look at `code_lowered` and `code_typed`).
For the same C code, the lowered IR from Clang looks similar, but it appears to constant fold and reduce down to identical assembly at `-O1` and above. The fact that Julia doesn't is probably due to difference in LLVM optimization passes or order.
As far as style, personally I think the first one is cleaner.