From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 092A13858D28 for ; Tue, 4 Oct 2022 13:27:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 092A13858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664890043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lDZ43ki8a6omPnbpo7cD4RtE9B7Sdgq1pDkOUrF2jBA=; b=YmKpjfA/SNu1OWjOjipTP1ztfICfVItVlYADGdbQU6+uH8Z1/xrv8LV1kdn7Lp8oagAG7W 61B7q47FsfXh+01f/Lv7JKhxNm3I3x7gOZTA96t5x2spW2b0/Renxg+oGfSmgwfWDrXpmk WJ6CUs9rI9ASF5y4CKdPLT2o+QSXB14= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-65-MMhq5yu5MEq_FJZvqXS4-w-1; Tue, 04 Oct 2022 09:27:22 -0400 X-MC-Unique: MMhq5yu5MEq_FJZvqXS4-w-1 Received: by mail-qv1-f71.google.com with SMTP id ok8-20020a0562143c8800b004b07e9ca57eso6933728qvb.19 for ; Tue, 04 Oct 2022 06:27:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=lDZ43ki8a6omPnbpo7cD4RtE9B7Sdgq1pDkOUrF2jBA=; b=6Gco/thQUXmMmYSqQMrJHKJWBjAz/lqxNnFE1XeaxwcVNy7y540aIOY43WYM1OWoBQ UEygJdQp+BHUQpUTvPZIhnCr0O8FirWpvzKVhWEAMgkvuLByiPlar54QAqQ4ZtNR+OfY QIYYzZuwrObu+IgZXlPToFzIexVbKTcZ6xCY8PI2SGigB4tPB0mcdVbJNVLNlhSQirf1 NAPr3r5eJ1Vlv1PaFHRNbiQ2CJE5lAvr5AGIPZeE0xVv9FjREfKv9Y1oP9f4WHmt0G2Y IZjRupL6bgI9LBEgQVF5HPi1a3f0Tlv/CKLYMsQYg/Ig0mLLnB8jAv4XNVwzdLe53B5d nUXg== X-Gm-Message-State: ACrzQf3F2VbBkFhdPGLTYBMoDXpReZC765diIOwiC+g8LV6GIdNFcqUn CuSlBX/mF0+b0k7yBIWW6hlfM4JsiRIv+Nu/KXTJVgBeW9kquKCSpVTU/0yPWpweRpZ5Z01Ped8 HIY7GF1jKzbWQNAoj9g== X-Received: by 2002:a05:620a:2a0b:b0:6ce:afaa:b87c with SMTP id o11-20020a05620a2a0b00b006ceafaab87cmr16533951qkp.665.1664890042240; Tue, 04 Oct 2022 06:27:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zWfwVfn/at79SxjnJkUZa2P9xlDYU5Mqw99yvFf/kY1OABYD2A2kCEUyFBjRYFPqXQppKSw== X-Received: by 2002:a05:620a:2a0b:b0:6ce:afaa:b87c with SMTP id o11-20020a05620a2a0b00b006ceafaab87cmr16533937qkp.665.1664890042026; Tue, 04 Oct 2022 06:27:22 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::3dbe? ([2607:fea8:a263:f600::3dbe]) by smtp.gmail.com with ESMTPSA id m16-20020a05620a291000b006c73c3d288esm14338262qkp.131.2022.10.04.06.27.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Oct 2022 06:27:21 -0700 (PDT) Message-ID: <55c5aebd-6b51-982b-3dc7-73513c727f58@redhat.com> Date: Tue, 4 Oct 2022 09:27:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [COMMITTED] Convert nonzero mask in irange to wide_int. To: Aldy Hernandez , Richard Biener Cc: GCC patches References: <20221004073530.1461390-1-aldyh@redhat.com> From: Andrew MacLeod In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/4/22 08:13, Aldy Hernandez via Gcc-patches wrote: > On Tue, Oct 4, 2022, 13:28 Aldy Hernandez wrote: > >> On Tue, Oct 4, 2022 at 9:55 AM Richard Biener >> wrote: >>> >>> Am 04.10.2022 um 09:36 schrieb Aldy Hernandez via Gcc-patches < >> gcc-patches@gcc.gnu.org>: >>>> The reason the nonzero mask was kept in a tree was basically inertia, >>>> as everything in irange is a tree. However, there's no need to keep >>>> it in a tree, as the conversions to and from wide ints are very >>>> annoying. That, plus special casing NULL masks to be -1 is prone >>>> to error. >>>> >>>> I have not only rewritten all the uses to assume a wide int, but >>>> have corrected a few places where we weren't propagating the masks, or >>>> rather pessimizing them to -1. This will become more important in >>>> upcoming patches where we make better use of the masks. >>>> >>>> Performance testing shows a trivial improvement in VRP, as things like >>>> irange::contains_p() are tied to a tree. Ughh, can't wait for trees in >>>> iranges to go away. >>> You want trailing wide int storage though. A wide_int is quite large. >> Absolutely, this is only for short term storage. Any time we need >> long term storage, say global ranges in SSA_NAME_RANGE_INFO, we go >> through vrange_storage which will stream things in a more memory >> efficient manner. For irange, vrange_storage will stream all the >> sub-ranges, including the nonzero bitmask which is the first entry in >> such storage, as trailing_wide_ints. >> >> See irange_storage_slot to see how it lives in GC memory. >> > That being said, the ranger's internal cache uses iranges, albeit with a > squished down number of subranges (the minimum amount to represent the > range). So each cache entry will now be bigger by the difference between > one tree and one wide int. > > I wonder if we should change the cache to use vrange_storage. If not now, > then when we convert all the subranges to wide ints. > > Of course, the memory pressure of the cache is not nearly as problematic as > SSA_NAME_RANGE_INFO. The cache only stores names it cares about. Rangers cache can be a memory bottleneck in pathological cases.. Certainly not as bad as it use to be, but I'm sure it can still be problematic.    Its suppose to be a memory efficient representation because of that.  The cache can have an entry for any live ssa-name (which means all of them at some point in the IL) multiplied by a factor involving the number of dominator blocks and outgoing edges ranges are calculated on.   So while SSA_NAME_RANGE_INFO is a linear thing, the cache lies somewhere between a logarithmic and exponential factor based on the CFG size. if you are growing the common cases of 1 to 2 endpoints to more than double in size (and most of the time not be needed), that would not be very appealing :-P  If we have any wide-ints, they would need to be a memory efficient version.   The Cache uses an irange_allocator, which is suppose to provide a memory efficient objects.. hence why it trims the number of ranges down to only what is needed.  It seems like a trailing wide-Int might be in order based on that.. Andrew PS. which will be more problematic if you eventually introduce a known_ones wide_int.    I thought the mask tracking was/could be something simple like  HOST_WIDE_INT..  then you only tracks masks in types up to the size of a HOST_WIDE_INT.  then storage and masking is all trivial without going thru a wide_int.    Is that not so/possible? > Aldy >