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 2184A3858419 for ; Tue, 4 Oct 2022 15:14:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2184A3858419 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=1664896472; 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=5vzAdbdWlExjcwPGNdzKYOJcWkbI/ts4xjDhjB+tb4Q=; b=PdHuhQMwfP30e3em9TisQU7IubHAV1/P/C1jlMGITEyQoerKvZUTdUcYv8UBXLMxnoFYJI sZt0FtVu2d/HfJ9ahxLFj/BGcpczGz14Jum8F+BY6uGnQ/Xvvh4/3U24ibulWCd/oe9Cvr LWzTy+UXvdZBy1JOGeP7ULbku5DUmDc= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-561-rdG_ueFXNo-AQ6_V1h6DHg-1; Tue, 04 Oct 2022 11:14:31 -0400 X-MC-Unique: rdG_ueFXNo-AQ6_V1h6DHg-1 Received: by mail-oi1-f197.google.com with SMTP id bl2-20020a056808308200b0035028763f44so5404405oib.19 for ; Tue, 04 Oct 2022 08:14:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=5vzAdbdWlExjcwPGNdzKYOJcWkbI/ts4xjDhjB+tb4Q=; b=CRqYj00om2ninpxb0AKjGEXtgV3oOObJlgPbrzmmbwcAN1sWEBDE6FafUwQhiSgpNx xtjQ2BHnCjzwKGRaz83xKttGWsUPANPWjrABFz1pTCEVptKp88nw5T4rHEh1uikQ8XZm cEAOjK1rSMK67TlNP5EIA7p2N2tMaRPthT92mBYwfHA/5hxI0xMoG9E3N6d7hZOiN0BQ 7f3Cid8UF2aqq5GEEFWtqvkd7etiRxYf0IxesMAh87/hCOwVuKX1lKYjbj0jDEAv/DNY Fr7n6PYdlibE3f4z64SRZdu1n9pXMPSN5qo/fTZrTjhERw+MbNmaGFDxCJz8rIpS6X+u hfXw== X-Gm-Message-State: ACrzQf0A4SXPreC6ndc/CyviwnvjnWW0Siggc8R/4Az/YCxXzMwErfvb yc+q0Ud4H0QO0O4cSGh5SPTn8xknmJ3qaB4Ctkt7jcKaLIsKyP4UiPyIW5eGOmaHnLSFClcduev 9az7CAbsoGhkpdHlq6bEWrcPCbg17wxPsaw== X-Received: by 2002:a9d:4709:0:b0:655:b51e:fc6a with SMTP id a9-20020a9d4709000000b00655b51efc6amr10385755otf.276.1664896470273; Tue, 04 Oct 2022 08:14:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gY1IC/Wiv1yDe4fXEhL/OL6SMsLUuYaNUMUVhC40f5c3encNyblJwwsGoXG8A+FQYa/tE0R9bbt9V2fSY9EE= X-Received: by 2002:a9d:4709:0:b0:655:b51e:fc6a with SMTP id a9-20020a9d4709000000b00655b51efc6amr10385735otf.276.1664896469940; Tue, 04 Oct 2022 08:14:29 -0700 (PDT) MIME-Version: 1.0 References: <07FCA378-7E86-4E06-B506-FED0C60CE31C@gmail.com> In-Reply-To: <07FCA378-7E86-4E06-B506-FED0C60CE31C@gmail.com> From: Aldy Hernandez Date: Tue, 4 Oct 2022 17:14:18 +0200 Message-ID: Subject: Re: [COMMITTED] Convert nonzero mask in irange to wide_int. To: Richard Biener Cc: Andrew MacLeod , GCC patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Tue, Oct 4, 2022 at 4:34 PM Richard Biener wrote: > > > > > Am 04.10.2022 um 16:30 schrieb Aldy Hernandez : > > > > =EF=BB=BFOn Tue, Oct 4, 2022 at 3:27 PM Andrew MacLeod wrote: > >> > >> > >>> 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>: > >>>>>> =EF=BB=BFThe reason the nonzero mask was kept in a tree was basica= lly inertia, > >>>>>> as everything in irange is a tree. However, there's no need to ke= ep > >>>>>> 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 tre= es in > >>>>>> iranges to go away. > >>>>> You want trailing wide int storage though. A wide_int is quite lar= ge. > >>>> 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 i= n > >>>> 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 wit= h a > >>> squished down number of subranges (the minimum amount to represent th= e > >>> range). So each cache entry will now be bigger by the difference bet= ween > >>> 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 problema= tic 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 fact= or > >> 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 base= d > >> on the CFG size. > > > > Hmmm, perhaps the ultimate goal here should be to convert the cache to > > use vrange_storage, which uses trailing wide ints for all of the end > > points plus the masks (known_ones included for the next release). > > > >> > >> 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 trailin= g > >> 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? > > > > That's certainly easy and cheaper to do. The hard part was fixing all > > the places where we weren't keeping the masks up to date, and that's > > done (sans any bugs ;-)). > > > > Can we get consensus here on only tracking masks for type sizes less > > than HOST_WIDE_INT? I'd hate to do all the work only to realize we > > need to track 512 bit masks on a 32-bit host cross :-). > > 64bits are not enough, 128 might be. But there=E2=80=99s trailing wide i= nt storage so I don=E2=80=99t see the point in restricting ourselves? Fair enough. Perhaps we should bite the bullet and convert the cache to vrange_storage which is all set up for streaming irange's with trailing_wide_ints. No changes should be necessary for irange, since we never have more than 3-4 live at any one time. It's the cache that needs twiddling. Aldy