The problem with T51023 is that the Mix node wasn't bypassed since its clamp was enabled. But, if it was possible to bypass the Mix, but not the Clamp, one of the images could be ignored.
So, this patch adds two Clamp nodes to Cycles - one for values and one for colors. They're NOT exposed to the user - instead, when a Mix/Math node with clampling enabled is synced, Cycles turns it into a Mix/Math node plugged into a Clamp node.
This makes the code cleaner - the Mix/Math nodes just compile to one SVM instruction, the constant folder can be simplified (since clamping isn't a weird special case anymore) and situations like the one in T51023 are optimized correctly.