I'm not a compiler expert, but I would be very surprised if a GLSL compiler did not do simple constant folding. So I think it should be safe to assume that the division of the constant in the following case gets evaluated at compile time:
vec2 x = y * (1.0 / 256.0);
The second case is actually much more interesting:
vec2 x = y / 256.0;
If this were C or C++ code, my understanding is that a compiler would not replace this by a multiplication by default. The reason is that it could not be guaranteed that the result would be identical to the last bit, due to different rounding. For reference, see the answers in Optimizing a floating point division and conversion operation, where one of the answers confirms that for example gcc does not do the replacement unless the -freciprocal-math
compiler option is used.
However, GLSL is a different case. The OpenGL ES GLSL spec specifically allows this type of transformation:
The C++ standard requires that expressions must be evaluated in the order specified by the precedence of operations and may only be regrouped if the result is the same or where the result is undefined. No other transforms may be applied that affect the result of an operation. GLSL ES relaxes these requirements in the following ways:
...
Floating point division may be replaced by reciprocal and multiplication.
Interestingly, this is not part of the full (i.e. non-ES) GLSL spec. It does have precision requirements, which say that the error of a division can be at most 2.5 ULP (units in the last place). The way I interpret this, if the replacement of a division by a multiplication meets that precision requirement, the substitution would be legal. But to be sure that your code is as efficient as it can be, it still seems safer to use multiplications instead of divisions where possible.