From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by sourceware.org (Postfix) with ESMTPS id 47E243858404 for ; Tue, 19 Oct 2021 07:28:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 47E243858404 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 575202E1843; Tue, 19 Oct 2021 07:28:47 +0000 (UTC) Received: from pdx1-sub0-mail-a17.g.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id DB23A2E1840; Tue, 19 Oct 2021 07:28:46 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a17.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.112.147.114 (trex/6.4.3); Tue, 19 Oct 2021 07:28:47 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Shoe-Reaction: 3db69f9048f6daae_1634628527204_2373986917 X-MC-Loop-Signature: 1634628527204:408108201 X-MC-Ingress-Time: 1634628527203 Received: from pdx1-sub0-mail-a17.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a17.g.dreamhost.com (Postfix) with ESMTP id 38BFA8349A; Tue, 19 Oct 2021 00:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gotplt.org; h=message-id :date:mime-version:subject:to:cc:references:from:in-reply-to :content-type:content-transfer-encoding; s=gotplt.org; bh=G735il NFGxhJ8CL0UZ9cJ/ntUpI=; b=ERR1Nq+PUyue4ggG4X04LE7XvlnmzDWjZISxON yJtOisEPJggE4mIFhf2xFo6fADf0h9PlxnAaP3PaYHy7g/guQ5a0EbCZ2xvYBPmi 9auLUEqnaXVj4E0IX9RytIkMpJhreAcmzl/wSFvcX6rNDfMW0tQaPs9ld1+q2w1V YS3KQ= Received: from [192.168.1.174] (unknown [1.186.123.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a17.g.dreamhost.com (Postfix) with ESMTPSA id 876388348D; Tue, 19 Oct 2021 00:28:39 -0700 (PDT) Message-ID: <97e3c9dc-6b8c-fdb8-8cf0-2e929aac6b12@gotplt.org> Date: Tue, 19 Oct 2021 12:58:34 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH] tree-object-size: Make unknown a computation Content-Language: en-US To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <20211019041745.199156-1-siddhesh@gotplt.org> <20211019065813.GJ304296@tucnak> X-DH-BACKEND: pdx1-sub0-mail-a17 From: Siddhesh Poyarekar In-Reply-To: <20211019065813.GJ304296@tucnak> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3031.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SBL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2021 07:28:50 -0000 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