From: Jakub Jelinek <jakub@redhat.com>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] tree-optimization/104941: Actually assign the conversion result
Date: Wed, 16 Mar 2022 16:04:54 +0100 [thread overview]
Message-ID: <YjH8ltrE433t9Yjs@tucnak> (raw)
In-Reply-To: <20220316145424.1807869-1-siddhesh@gotplt.org>
On Wed, Mar 16, 2022 at 08:24:24PM +0530, Siddhesh Poyarekar wrote:
> Assign the result of fold_convert to offset.
>
> gcc/ChangeLog:
>
> PR tree-optimization/104941
> * tree-object-size.cc (size_for_offset): Assign result of
> fold_convert to OFFSET.
>
> gcc/testsuite/ChangeLog:
>
> PR tree-optimization/104941
> * gcc.dg/builtin-dynamic-object-size-0.c (S1, S2): New structs.
> (test_alloc_nested_structs, g): New functions.
> (main): Call test_alloc_nested_structs.
>
> Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
> --- a/gcc/tree-object-size.cc
> +++ b/gcc/tree-object-size.cc
> @@ -372,7 +372,7 @@ size_for_offset (tree sz, tree offset, tree wholesize = NULL_TREE)
>
> /* Safe to convert now, since a valid net offset should be non-negative. */
> if (!types_compatible_p (TREE_TYPE (offset), sizetype))
> - fold_convert (sizetype, offset);
> + offset = fold_convert (sizetype, offset);
>
> if (TREE_CODE (offset) == INTEGER_CST)
> {
I think the types_compatible_p call is too heavy, you want to check if
emitting the fold_convert to sizetype is unnecessary, which is
if (!useless_type_conversion_p (sizetype, TREE_TYPE (offset)))
offset = fold_convert (sizetype, offset);
types_compatible_p is that the conversion is useless in both directions.
Ok for trunk with that change.
Jakub
prev parent reply other threads:[~2022-03-16 15:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-16 14:54 Siddhesh Poyarekar
2022-03-16 15:04 ` Jakub Jelinek [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=YjH8ltrE433t9Yjs@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=siddhesh@gotplt.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).