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 CF3EF3858013 for ; Mon, 10 Jan 2022 13:52:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF3EF3858013 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-327-P1r8xbBzOWaLQFBtjGnSXA-1; Mon, 10 Jan 2022 08:52:03 -0500 X-MC-Unique: P1r8xbBzOWaLQFBtjGnSXA-1 Received: by mail-qk1-f198.google.com with SMTP id o196-20020a37a5cd000000b0047743cf5c29so7864190qke.18 for ; Mon, 10 Jan 2022 05:52:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=5IX96rhTAX2yomPUefA5TaLF9YOlG2I3D1oejXpq1oQ=; b=gureh9uylQphHpJ0wqHCJM74u8aJA9cgXlrYVCqturak+hLahIUbl6fQFzYlFA0IZS rXrTXn4JE8UondnXtU4yMh3wfVCDyH0GVPUZRkS/uQuMFFHq6yT5mULlO/ay3SSwsDMP 7sIbmskNYjKl3ffiud1rIO3cP30MYZ9LwfrT4co/PGUthobsOREXjHm1OpqpiGsdWZhB +ufhRBZpwJuetweQTzZ7EUB8o5bTi8sog9Q74QRIAc6j9gN3wBe9jHoTzEE15W2SVvGn 8k+Xyy/Q7+TT76DA/+f9gM1vQdkDrReJ5idpZsphhTaI3vuzUVEVaFKq/9fy59HsHaDR 7P/w== X-Gm-Message-State: AOAM533QKVsGhxmelUefmY+n7gizZazZ4x/HaUc16DXzHGJ/EWnTDA0F J/GUdBNosS0govJwlHzAdKm4xBEM+mEQKrb5IrsPEJSQU9CK2LipcQ1KeUnTfI2qRVtFz0SqMzH lg0/Ga2mYuKTTDNY1ZePy6/iEx2p0DFDE8ojtZDEgknYtKzVTJN3fE75203nIAy6YKTUjgg== X-Received: by 2002:a05:6214:27cf:: with SMTP id ge15mr68796286qvb.129.1641822723043; Mon, 10 Jan 2022 05:52:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxN2Vqr33FfPDf3LAi3YFZdor80Vdg4SGPOBN0wTs3Vu2jx4a0MvfVrkXukhw/HDTRYhFG37g== X-Received: by 2002:a05:6214:27cf:: with SMTP id ge15mr68796268qvb.129.1641822722774; Mon, 10 Jan 2022 05:52:02 -0800 (PST) Received: from [192.168.1.113] ([69.165.238.126]) by smtp.gmail.com with ESMTPSA id f9sm4451831qkp.94.2022.01.10.05.52.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jan 2022 05:52:02 -0800 (PST) Message-ID: <620cccc0-8276-8000-10f3-f47e32007711@redhat.com> Date: Mon, 10 Jan 2022 08:52:01 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH 6/6] ira: Handle "soft" conflicts between cap and non-cap allocnos To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com References: From: Vladimir Makarov 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=-6.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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: Mon, 10 Jan 2022 13:52:07 -0000 On 2022-01-06 09:48, Richard Sandiford wrote: > This patch looks for allocno conflicts of the following form: > > - One allocno (X) is a cap allocno for some non-cap allocno X2. > - X2 belongs to some loop L2. > - The other allocno (Y) is a non-cap allocno. > - Y is an ancestor of some allocno Y2 in L2. > - Y2 is not referenced in L2 (that is, ALLOCNO_NREFS (Y2) == 0). > - Y can use a different allocation from Y2. > > In this case, Y's register is live across L2 but is not used within it, > whereas X's register is used only within L2. The conflict is therefore > only "soft", in that it can easily be avoided by spilling Y2 inside L2 > without affecting any insn references. > > In principle we could do this for ALLOCNO_NREFS (Y2) != 0 too, with the > callers then taking Y2's ALLOCNO_MEMORY_COST into account. There would > then be no "cliff edge" between a Y2 that has no references and a Y2 that > has (say) a single cold reference. > > However, doing that isn't necessary for the PR and seems to give > variable results in practice. (fotonik3d_r improves slightly but > namd_r regresses slightly.) It therefore seemed better to start > with the higher-value zero-reference case and see how things go. > > On top of the previous patches in the series, this fixes the exchange2 > regression seen in GCC 11. > > gcc/ > PR rtl-optimization/98782 > * ira-int.h (ira_soft_conflict): Declare. > * ira-costs.c (max_soft_conflict_loop_depth): New constant. > (ira_soft_conflict): New function. > (spill_soft_conflicts): Likewise. > (assign_hard_reg): Use them to handle the case described by > the comment above ira_soft_conflict. > (improve_allocation): Likewise. > * ira.c (check_allocation): Allow allocnos with "soft" conflicts > to share the same register. > > gcc/testsuite/ > * gcc.target/aarch64/reg-alloc-4.c: New test. OK.  If something goes wrong with the patches (e.g. a lot of GCC testsuite failures or performance degradation), we can revert only the last 3 of them as ones actually changing the heuristics.  But I hope it will be not necessary. Thank you again for working on the PR.  Fixing it required big efforts in thinking, testing and benchmarking.