If m,n and h are the same for every thread, then this will limit a part of the divergence.
To make it perfect, every warp of threads should agree on which condition is taken.
The key is that every thread in a warp needs to execute the same instruction, so if your condition is warp dependant, then this should be fine.
If not, then the warp will have to be split in multiple “sub warps” which will leave some of the scalar processors idle, thus hurting performances.
I would first try it as is, then try it with a fake “optical” case to see if it is actually worth the trouble of possibly rearanging things to make the condition warp dependant.
It could very well be that you will be that this divergence will not be the limiting factor of your algorithm.