glsl: Move common code out of opt_algebraic's handle_expression().