Interestingly only clang understands that an upcast will prevent the overflow: int foo(unsigned int a) { if (a > 5) return ((unsigned long long)a * 3) / 3; else return 0; } Is compiled to compact code in clang: xorl %eax, %eax cmpl $5, %edi cmoval %edi, %eax retq