From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] tree-object-size: Make unknown a computation
Date: Tue, 19 Oct 2021 12:58:34 +0530 [thread overview]
Message-ID: <97e3c9dc-6b8c-fdb8-8cf0-2e929aac6b12@gotplt.org> (raw)
In-Reply-To: <20211019065813.GJ304296@tucnak>
On 10/19/21 12:28, Jakub Jelinek wrote:
> On Tue, Oct 19, 2021 at 09:47:45AM +0530, Siddhesh Poyarekar wrote:
>> Compute the unknown size value as a function of the min/max bit of
>> object_size_type. This transforms into a neat little branchless
>> sequence on x86_64:
>>
>> movl %edi, %eax
>> sarl %eax
>> xorl $1, %eax
>> negl %eax
>> cltq
>>
>> which should be faster than loading the value from memory. A quick
>> unscientific test using
>>
>> `time make check-gcc RUNTESTFLAGS="dg.exp=builtin*"`
>
> But if you use some other higher bit of object_size_type for the mode
> (normal vs. dynamic) you'd need to mask it away, so it will become longer.
> Anyway, I guess that part is ok.
Yes, my WIP patchset has:
((unsigned HOST_WIDE_INT) -(((object_size_type & MIN_BIT) >> 1) ^ 1));
which results in:
xorl %eax, %eax
andl $2, %edi
sete %al
negq %rax
>> -/* Compute object_sizes for PTR, defined to an unknown value. */
>> -
>> -static void
>> -unknown_object_size (struct object_size_info *osi, tree ptr)
>> -{
>> - int object_size_type = osi->object_size_type;
>> - unsigned int varno = SSA_NAME_VERSION (ptr);
>> - unsigned HOST_WIDE_INT bytes;
>> -
>> - gcc_assert (object_sizes[object_size_type][varno]
>> - != unknown[object_size_type]);
>> - gcc_assert (osi->pass == 0);
>> -
>> - bytes = unknown[object_size_type];
>> -
>> - if ((object_size_type & 2) == 0)
>> - {
>> - if (object_sizes[object_size_type][varno] < bytes)
>> - object_sizes[object_size_type][varno] = bytes;
>> - }
>> - else
>> - {
>> - if (object_sizes[object_size_type][varno] > bytes)
>> - object_sizes[object_size_type][varno] = bytes;
>> - }
>> -}
>
> But I don't think removing this function is desirable.
> Can it be greatly simplified? Yes, certainly.
> The assert verifies it is not unknown before, and then for mode 0 or 1
> uses maximum which will always be unknown and for mode 2 or 3
> minimum which will always be unknown as well.
> But I'd keep the asserts in there. So it can become
> int object_size_type = osi->object_size_type;
> unsigned int varno = SSA_NAME_VERSION (ptr);
> unsigned HOST_WIDE_INT bytes = unknown (object_size_type);
>
> gcc_checking_assert (object_sizes[object_size_type][varno] != bytes);
> gcc_checking_assert (osi->pass == 0);
> object_sizes[object_size_type][varno] = bytes;
OK, I'll send an updated patch.
Thanks,
Siddhesh
next prev parent reply other threads:[~2021-10-19 7:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 4:17 Siddhesh Poyarekar
2021-10-19 6:58 ` Jakub Jelinek
2021-10-19 7:28 ` Siddhesh Poyarekar [this message]
2021-10-19 7:38 ` [PATCH v2] " Siddhesh Poyarekar
2021-10-19 7:45 ` Jakub Jelinek
2021-10-20 3:00 ` Siddhesh Poyarekar
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=97e3c9dc-6b8c-fdb8-8cf0-2e929aac6b12@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/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).