My gut feeling would say "yes, but only on certain graphics drivers as it depends on the GLSL shader compiler doing this optimization".
I would recommend looking at the generated shader assembly to make sure: https://shader-playground.timjones.io/
Godot's shader language compiles to GLSL, so you can try to enter similar GLSL code and see how it's optimized on various GPU architectures. Godot's shader language itself doesn't perform any optimizations. It's up to the driver's GLSL compiler to perform such optimizations.