I understand that all but the most high-end graphics cards do not do true branching, but evaluate both branches and then pick one result. Normally, I can live with that. But I've run into a case where evaluating the wrong branch causes a division by 0, crashing the driver, and I don't know how to fix it.

The specific expression is

(q <= 0.0)? v : floor( v * q + vec3(0.5) ) / q

where q is a uniform float and v is a local vec3. Any ideas?