From patchwork Thu Aug 17 16:02:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1822437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=WtIzrbk0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RRVCK5t7pz20Bh for ; Fri, 18 Aug 2023 02:02:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B638385483D for ; Thu, 17 Aug 2023 16:02:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B638385483D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692288171; bh=HH/SkzPlqZU+ezN1lr0ju+VJ5VNV+n4cdnsQHdkkL08=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WtIzrbk0Iw35jOI4OPiR5e7t8LOfRMvBv07QWEoenW0ziFsb+2FH6jw4mMZu7GcG5 8K8DGvHwcAWXm0fIHA5GLl0QMn3fC26WVpSE/2gSXS/Vm8lZA8P+h9kecf12g8SPaJ rB3HSuj+Nkrqg5s8lE2+nPS2l+/8y1M4oqvNhz3E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 127453858D35 for ; Thu, 17 Aug 2023 16:02:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 127453858D35 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-1lJI1VD4O5ylHw0rTSKugg-1; Thu, 17 Aug 2023 12:02:27 -0400 X-MC-Unique: 1lJI1VD4O5ylHw0rTSKugg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-76d83954c41so47379085a.2 for ; Thu, 17 Aug 2023 09:02:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692288146; x=1692892946; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wFT8PdWS89gDyQRtgHY5ik7IDipwENErKEjqJl7BLKo=; b=lxaZKH2b4JxJZdj+eo7XDod3a3uqtn1537tQw+OwQzspMMjaXJgxRTEK/qz9VS7D5k 1evvaKHn0OQRdMOtiL7emAAb0+tJiEZvsbU36iuecCBh1yFNjbzL4ksuyQ29J127/PpT UbE+/7/+8jDAlodm8Bd1Fn79vTBJuR52S5EHwWmS2Y7HWSZc1BKpad/iTGNloCiLSMme rOlS2Cfc4BdJsE3RAV1+fM1bz7ca7zYDAnUIsaEbcsC07PrSf5MC6EPUnru9fKzOkY3Y DZg3XDGN9UchkB5+e4WBDDN4Q4mXoEz7caOkhudYD1iM9bpGS6waz5w0ltMY6FFWTEq1 4n1Q== X-Gm-Message-State: AOJu0YxO6saOVEA48jzPmfgKZkn+0uua49oizRmirShX+vuEUr+G3Lpv rcvC2Sm1rarVo8juUG+RiDvkwzWdDlTH9x8uDUqgn3lANEKOEbsqv6QedAUhOuT9FrfeUtu4yyn dTGSDFlj4pGWfjTcqwIv0TTdHoec+Fw12Brem53lHHeV1bKxPQ5I4/cZ+oEn55td1EgLaXA/Vmj OCDg== X-Received: by 2002:a05:620a:269a:b0:76c:9eab:41ad with SMTP id c26-20020a05620a269a00b0076c9eab41admr76815qkp.32.1692288145937; Thu, 17 Aug 2023 09:02:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIYGu23WYkk2CpavLOkOm+XrPnr2K86wLaowh8KgBxMy9GSb5tyYU+HKJVr8vJdbaQ+SKDJA== X-Received: by 2002:a05:620a:269a:b0:76c:9eab:41ad with SMTP id c26-20020a05620a269a00b0076c9eab41admr76781qkp.32.1692288145553; Thu, 17 Aug 2023 09:02:25 -0700 (PDT) Received: from [192.168.1.88] (192-0-143-139.cpe.teksavvy.com. [192.0.143.139]) by smtp.gmail.com with ESMTPSA id q29-20020a05620a039d00b0076c96e571f3sm5241528qkm.26.2023.08.17.09.02.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Aug 2023 09:02:24 -0700 (PDT) Message-ID: <8d04289d-a00e-20e0-38ce-c18b525d62b3@redhat.com> Date: Thu, 17 Aug 2023 12:02:23 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: "gcc-patches@gcc.gnu.org" , SenthilKumar.Selvaraj@microchip.com Subject: [pushed][LRA]: When assigning stack slots to pseudos previously assigned to fp consider other spilled pseudos X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 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-Patchwork-Original-From: Vladimir Makarov via Gcc-patches From: Vladimir Makarov Reply-To: Vladimir Makarov Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The following patch fixes a problem with allocating the same stack slots to conflicting pseudos.  The problem exists only for AVR LRA port. The patch was successfully bootstrapped and tested on x86-64 and aarch64. commit c024867d1aa9d465e0236fc9d45d8e1d4bb6bd30 Author: Vladimir N. Makarov Date: Thu Aug 17 11:57:45 2023 -0400 [LRA]: When assigning stack slots to pseudos previously assigned to fp consider other spilled pseudos The previous LRA patch can assign slot of conflicting pseudos to pseudos spilled after prohibiting fp->sp elimination. This patch fixes this problem. gcc/ChangeLog: * lra-spills.cc (assign_stack_slot_num_and_sort_pseudos): Moving slots_num initialization from here ... (lra_spill): ... to here before the 1st call of assign_stack_slot_num_and_sort_pseudos. Add the 2nd call after fp->sp elimination. diff --git a/gcc/lra-spills.cc b/gcc/lra-spills.cc index 7e1d35b5e4e..a663a1931e3 100644 --- a/gcc/lra-spills.cc +++ b/gcc/lra-spills.cc @@ -363,7 +363,6 @@ assign_stack_slot_num_and_sort_pseudos (int *pseudo_regnos, int n) { int i, j, regno; - slots_num = 0; /* Assign stack slot numbers to spilled pseudos, use smaller numbers for most frequently used pseudos. */ for (i = 0; i < n; i++) @@ -628,6 +627,7 @@ lra_spill (void) /* Sort regnos according their usage frequencies. */ qsort (pseudo_regnos, n, sizeof (int), regno_freq_compare); n = assign_spill_hard_regs (pseudo_regnos, n); + slots_num = 0; assign_stack_slot_num_and_sort_pseudos (pseudo_regnos, n); for (i = 0; i < n; i++) if (pseudo_slots[pseudo_regnos[i]].mem == NULL_RTX) @@ -635,6 +635,7 @@ lra_spill (void) if ((n2 = lra_update_fp2sp_elimination (pseudo_regnos)) > 0) { /* Assign stack slots to spilled pseudos assigned to fp. */ + assign_stack_slot_num_and_sort_pseudos (pseudo_regnos, n2); for (i = 0; i < n2; i++) if (pseudo_slots[pseudo_regnos[i]].mem == NULL_RTX) assign_mem_slot (pseudo_regnos[i]);