Saturated signed addition
Undefined behavior from signed overflow
Technically, your first line causes undefined behavior:

int sum = x + y;


It should be written instead as:
int sum = (unsigned int) x + y;

In C, signed integer overflow is undefined behavior but unsigned integer overflow is not.  Your compiler probably will treat the two lines above identically, but to be safe you should use the unsigned add.
Save a couple of instructions
This line here could be optimized:

int mask = (~(x ^ y) &amp; (y ^ sum) &amp; (x ^ sum)) &gt;&gt; w;


to this:
int mask = (~(x ^ y) &amp; (x ^ sum)) &gt;&gt; w;

If x and y have the same sign, then you only need to check one of them against sum instead of both of them.  This saves 2 assembly instructions when you compile it.