public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102738] Failure to optimize right shift of 32-bit int after it's already been shifted by 31 Date: Thu, 14 Oct 2021 00:49:26 +0000 [thread overview] Message-ID: <bug-102738-4-ioC8zoEYiT@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102738-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102738 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2021-10-14 Summary|Failure to optimize right |Failure to optimize right |shift of 128-bit value |shift of 32-bit int after |after it's already been |it's already been shifted |shifted by 127 |by 31 Ever confirmed|0 |1 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- GCC does not even do the int case: int a(int f, int g) { return (f >> 31) >> g; } Actually this can be simplified down to this really (which clang does not handle but handles a simular case; see below): int a(int f, int g) { if (f == 0 || f == -1) return f >> g; __builtin_unreachable(); } This should just return f here :). Basically if GCC knows f is already 0 or -1, then f shifted by any value is still f. clang is able to handle this case though int a1(int f, int g) { if (f == 0 || f == 1) return (-f) >> g; __builtin_unreachable(); }
next prev parent reply other threads:[~2021-10-14 0:49 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-14 0:36 [Bug tree-optimization/102738] New: Failure to optimize right shift of 128-bit value after it's already been shifted by 127 gabravier at gmail dot com 2021-10-14 0:49 ` pinskia at gcc dot gnu.org [this message] 2021-10-14 0:53 ` [Bug tree-optimization/102738] Failure to optimize (signed) right shift if the range is already known to be [-1, 0] pinskia at gcc dot gnu.org 2021-10-14 1:55 ` pinskia at gcc dot gnu.org 2021-10-14 18:02 ` cvs-commit at gcc dot gnu.org 2021-10-14 18:03 ` amacleod at redhat dot com
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-102738-4-ioC8zoEYiT@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).