Kyle A. answered 05/05/20
Senior Software Engineer Specializing in Systems Programming
In most cases your compiler will optimize this for you and it is more important to convey clear meaning in your program. If semantically you want to divide by 2, then you should use division. Chances are your compiler knows the the best way to perform this operation for your target platform so it is usually better to let it decide whether to invoke a divide instruction or a shift. Most likely it will choose the shift since that is a less complicated operation for the hardware but this may not be true for all hardware and you should only optimize this in a way that might make your program harder to read if you profile your code and find the shift to be faster during your profiling.
In such a simple case, I think it would be very likely that the compiler would be able to optimize this but in more complicated cases you might be able to eek out some performance with manual tweaking like this so it is good that you are thinking about this stuff!