https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81281
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 42785 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42785&action=edit gcc8-pr81281-test.patch This was fixed by r251651 for -fsanitize=undefined. Attaching testcase in patch form. That said, without -fsanitize=unreachable the bug is still latent. If we start just with: int a = (int) (-2024172551 - (long long)ci); then we properly fold it into: int a = (int) (2270794745 - (unsigned int) ci);