Selecting max value and warp divergence

In my code I have the following situation (somewhat simplified here):
uint x =0;
uint a = ‘some math’;
uint b = ‘some other math’;
uint c = 'some more math;

now I would like to select the maximum value: x = max(x,a,b,c)

Whatever I use the max-function or construct if-statements (which max does I imagine), the performance drops by several factors. Is it true this come from warp divergence?
And is there some basic expression to select the maximum value? I’ve tried stuff like:
(( a-b ) >>(sizeof(uint)*8-1))*b but this is even slower than using if-statements…

Any help would be highly appreciated!

Edit: removed wierd smily from code…

If you never use the values a,b,c except in the max, uncommenting the max will cause the dead code optimizer to remove your ‘some math’. So you could be seeing performance degradation due to that.

Warp divergences in this circumstance are handled by the hardware very well and probably don’t change the performance at all.

Thanks, I was not aware the compiler removed ‘dead code’. Adding x=a+b+c i.s.o. if-statements did bring me back to the slow (relative of course ;-) performance.