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/109637] unnecessary range check in complete switch on bitfield
Date: Fri, 11 Aug 2023 00:39:23 +0000 [thread overview]
Message-ID: <bug-109637-4-vf9t42dYwY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109637-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109637
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Macleod from comment #2)
>
> Why are we adding -1 to [0,3] ? Thats the root of this issue I think?
> seems strange
if we ignore the range for a second.
When switch conversion happens we have:
switch (_1) <default: <L5> [INV], case 1: <L1> [INV], case 2: <L2> [INV],
case 3: <L3> [INV]>
So when _1 is either 0 or > 3, default case will happen.
The real problem is switch conversion promotes to a 8 bit type when it does the
comparisons and does not take into the ranges.
Related testcase (ignoring that there is a bogus warning, see PR 95513 for that
and not fixed even with my VRP patch):
```
int f (unsigned t) {
switch(t & 0x3) {
case 0: return 0;
case 1: return 1;
case 2: return 2;
case 3: return 3;
}
}
```
my VRP patch also fixes the above. Now switch conversion should use the range
info too. I will look into adding that .... But at least we get decent code for
the orginal and related cases now.
prev parent reply other threads:[~2023-08-11 0:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 18:17 [Bug middle-end/109637] New: " mattiase at acm dot org
2023-04-26 18:19 ` [Bug middle-end/109637] " pinskia at gcc dot gnu.org
2023-04-26 18:28 ` [Bug tree-optimization/109637] " pinskia at gcc dot gnu.org
2023-04-26 18:52 ` amacleod at redhat dot com
2023-04-26 19:02 ` amacleod at redhat dot com
2023-04-26 19:05 ` pinskia at gcc dot gnu.org
2023-04-26 19:16 ` amacleod at redhat dot com
2023-08-11 0:17 ` pinskia at gcc dot gnu.org
2023-08-11 0:39 ` pinskia at gcc dot gnu.org [this message]
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-109637-4-vf9t42dYwY@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: link
Be 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).