From: Jeff Law <law@redhat.com>
To: Philipp Tomsich <philipp.tomsich@vrull.eu>, gcc-patches@gcc.gnu.org
Cc: Philipp Tomsich <prt@gnu.org>
Subject: Re: [PATCH v1 1/2] Simplify shifts wider than the bitwidth of types
Date: Mon, 16 Nov 2020 16:38:20 -0700 [thread overview]
Message-ID: <abea99d7-34e9-6a2f-1637-ff3dd59248ee@redhat.com> (raw)
In-Reply-To: <1605553027-5331-1-git-send-email-philipp.tomsich@vrull.eu>
On 11/16/20 11:57 AM, Philipp Tomsich wrote:
> From: Philipp Tomsich <prt@gnu.org>
>
> While most shifts wider than the bitwidth of a type will be caught by
> other passes, it is possible that these show up for VRP.
> Consider the following example:
> int func (int a, int b, int c)
> {
> return (a << ((b && c) - 1));
> }
>
> This adds simplify_using_ranges::simplify_lshift_using_ranges to
> detect and rewrite such cases. If the intersection of meaningful
> shift amounts for the underlying type and the value-range computed
> for the shift-amount (whether an integer constant or a variable) is
> empty, the statement is replaced with the zero-constant of the same
> precision as the result.
>
> gcc/ChangeLog:
>
> * vr-values.h (simplify_using_ranges): Declare.
> * vr-values.c (simplify_lshift_using_ranges): New function.
> (simplify): Use simplify_lshift_using_ranges for LSHIFT_EXPR.
Umm, isn't this a shift wider than the bitwidth undefined behavior? We
should be generating warnings for that, not trying to further optimize
it :-)
jeff
next prev parent reply other threads:[~2020-11-16 23:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-16 18:57 Philipp Tomsich
2020-11-16 18:57 ` [PATCH v1 2/2] RISC-V: Adjust predicates for immediate shift operands Philipp Tomsich
2020-11-16 22:27 ` Jim Wilson
2020-11-16 22:45 ` Philipp Tomsich
2020-11-17 17:06 ` Jim Wilson
2020-11-16 22:38 ` [PATCH v1 1/2] Simplify shifts wider than the bitwidth of types Jim Wilson
2020-11-16 22:59 ` Philipp Tomsich
2020-11-16 23:38 ` Jeff Law [this message]
2020-11-17 11:53 ` Philipp Tomsich
2020-11-17 15:56 ` Jeff Law
2020-11-17 16:29 ` Philipp Tomsich
2020-11-17 16:46 ` Jakub Jelinek
2020-11-17 16:54 ` Jeff Law
2020-11-17 16:58 ` Jakub Jelinek
2020-11-18 23:46 ` Jeff Law
2020-11-17 17:23 ` Philipp Tomsich
2020-11-17 18:02 ` Jakub Jelinek
2020-11-17 17:14 ` Jim Wilson
2020-11-17 17:55 ` Jakub Jelinek
2020-11-17 16:35 ` Philipp Tomsich
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=abea99d7-34e9-6a2f-1637-ff3dd59248ee@redhat.com \
--to=law@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=philipp.tomsich@vrull.eu \
--cc=prt@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).