The compiler can't remove a branch is it has a dependency on a CB value, only if it constant during compilation.
The data in a constant buffer is not really constant... it is dynamic
Well yes, that is why I said "You will probably not be that lucky". Technically, constant memory is just normal memory of which you promise not to touch it, and on some architectures, it exists as dedicated L1 cache (in addition to the normal L1 cache, but it isn't being updated, ever). Insofar, all the compiler can tell is that you access "some memory" (which may be "some special memory", but still, some memory whose contents aren't known at that time).
In principle, however, the compiler can tell that it's constant at compile time, since you use the __constant__ keyword (in e.g. CUDA), and a clever compiler could in principle know that the data can never ever possibly change after you memcopied data using its API. There is no way your shader can modify the data, and there is no way you can access this data, except by the driver's public API, which the driver will immediately know about the moment you do. Thus, the compiler might secretly, on the fly, generate a special version of the shader based on what data you upload. In theory, that is. And, this may equally be a win or a loss, depending on how intrusive the recompilation is.
nVidia OpenGL drivers have been known to do that kind of thing in the past (I believe some 5-6 years ago), which has lent to big surprises for example when there was suddenly a small "hiccup" after setting an uniform to exactly 2.0 or 0.0 -- after which the frame rate "magically" went up. For some time, it was therefore recommended to use values like 2.00001 to avoid this "surprise". I'm not sure if drivers still do that kind of thing today, but it's conceivable.
Depending on how fast the compiler can generate an alternative binary (this is presumably much faster than parsing the whole thing and starting from scratch), you might not even notice that this happens between the time when you set the buffer and when you launch the kernel.