public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/90094] better handling of x == LONG_MIN on x86-64 Date: Wed, 14 Jun 2023 08:58:26 +0000 [thread overview] Message-ID: <bug-90094-4-hRD6XicdIj@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-90094-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90094 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |uros at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- But then shouldn't we do it not just for equality/non-equality comparisons against 0x8000000000000000, but also for equality/non-equality comparisons against 0x7fffffffffffffff or signed non-equality comparisons like > __LONG_MAX__ - 42 or >= __LONG_MAX__ - 0x7fffff00 etc. I mean void fn (void); unsigned f1 (long a) { return a == -__LONG_MAX__ - 1; } void f2 (long a) { if (a == -__LONG_MAX__ - 1) fn (); } unsigned f3 (long a) { return __builtin_sub_overflow_p (0, a, 0L); } void f4 (long a) { if (__builtin_sub_overflow_p (0, a, 0L)) fn (); } unsigned f5 (long a) { return a == __LONG_MAX__; } void f6 (long a) { if (a == __LONG_MAX__) fn (); } unsigned f7 (long a) { return __builtin_add_overflow_p (a, 1, 0L); } void f8 (long a) { if (__builtin_add_overflow_p (a, 1, 0L)) fn (); } unsigned f9 (long a) { return a >= __LONG_MAX__ - 42; } void f10 (long a) { if (a >= __LONG_MAX__ - 42) fn (); } unsigned f11 (long a) { return __builtin_add_overflow_p (a, 43, 0L); } void f12 (long a) { if (__builtin_add_overflow_p (a, 43, 0L)) fn (); } unsigned f13 (long a) { return a <= -__LONG_MAX__ + 42; } void f14 (long a) { if (a <= -__LONG_MAX__ + 42) fn (); } unsigned f15 (long a) { return __builtin_sub_overflow_p (a, 43, 0L); } void f16 (long a) { if (__builtin_sub_overflow_p (a, 43, 0L)) fn (); } The question if it should be done in the cstoredi4 and cbranchdi4 expanders, or matched later say during combine, or peephole2.
next prev parent reply other threads:[~2023-06-14 8:58 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-90094-4@http.gcc.gnu.org/bugzilla/> 2021-07-25 1:06 ` pinskia at gcc dot gnu.org 2023-06-14 6:11 ` eggert at cs dot ucla.edu 2023-06-14 8:58 ` jakub at gcc dot gnu.org [this message] 2023-06-14 9:00 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-90094-4-hRD6XicdIj@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).