https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98438
--- Comment #2 from Gabriel Ravier <gabravier at gmail dot com> --- Directly based off the emitted GIMPLE, here's a self-contained example that emits the same assembly I was observing before : using _Tp = int; using _Up = unsigned; _Tp f(_Tp __a, _Tp __b) { _Up __sign_bit_12; _Up __diff_11; unsigned int __b_0_1; unsigned int __a_1_2; bool _3; unsigned int _4; unsigned int _5; unsigned int _7; unsigned int _8; unsigned int _13; _Tp _14; unsigned int _17; __b_0_1 = (unsigned int) __b; __a_1_2 = (unsigned int) __a; __diff_11 = __b_0_1 - __a_1_2; _3 = __b < __a; __sign_bit_12 = (_Up) _3; _4 = __diff_11 >> 1; _5 = __sign_bit_12 << 31; _13 = _4 + _5; _7 = __diff_11 & __sign_bit_12; _17 = __a_1_2 + _7; _8 = _13 + _17; _14 = (_Tp) _8; return _14; }