From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by sourceware.org (Postfix) with ESMTPS id 447763858C2F for ; Tue, 17 Jan 2023 11:23:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 447763858C2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-4b6255ce5baso416992337b3.11 for ; Tue, 17 Jan 2023 03:23:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vWfahYsD5gHYjdoaj6E3jMkl8wuzZUWp8bHzSCHBvNc=; b=hD7WoWpqcB7nAtPSuxov1s8+tVWxQ6eQp7qqGztQfsIE2q0J4KELlAWB6lwNyj83Ik Uq1XUJUsQqyAD4OVmraDqGKpjsplfbu22PCJCHTI8FVWlBjzJVYynp/YIZAgjb3gqKvS /0yWjStRa4az2+UQmaDP7hwKXbV+cOWJ1/ReXgIDD8ge0+zj/gTjgVjUu7YUTD/BQ7Gv 6/7DFNgi156e1kAxnIK+eMC8n9VGavVIF23Xmo4/ouyKUdIsytqA+5i0lDpttGEKIGIL GPiQODZ0xTKT/bKuvV98UnFL+jiercS5zfeWSuM7PfWG1zXDWK577FhDqpgkJeTfKWfX u80A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vWfahYsD5gHYjdoaj6E3jMkl8wuzZUWp8bHzSCHBvNc=; b=nPcJXRnqAoerreQimXqtnUxM7PyCpUEOBUICJkgn8xiCfpPF/sGLlpUnmwz7W3cHP1 Uu8i7nXbKCpMVrGoxqSiJW6kz0aucIu4PzslqXpiBl2uTdb4AiGDV5cccvupuEo4Rf3h 4yUMz/H1tgwYlsP1NhnOI3IPnO0Hqp2tBbunAee80XSC+KltE3+dKHr80NnuvmdzW92a RYtWH8QBVLzOxUy+NJlOBhcs/fGgY80BPT0mQ2zTZbtAwmHs+D0Q+bJHRTSGKNXJImu/ fZcuDTFu8ChLuP3INbCLjLt5seoWsmZMlSY7X1nP2QMh2sW7ou1ybjOcMZ6s9Cd68tcb B8yQ== X-Gm-Message-State: AFqh2kptfSuZkSrCsqhXFMvWucrvT6OUA0MtIjstLb37Lh0sPce9yqaM I0pT6FBseRoPLWw7mW/JE9NMLX4/mD6bG8dZZfw= X-Google-Smtp-Source: AMrXdXtnNt/H7aeAmHCfgMMFEXvd3ApQz/P8FDv2o+rwnXR+bg8KBSd/NkdWYWWpGi22JBv1ZXtyGqaYhR0r+awHY9s= X-Received: by 2002:a0d:ead2:0:b0:4df:d33:ad27 with SMTP id t201-20020a0dead2000000b004df0d33ad27mr374971ywe.483.1673954603563; Tue, 17 Jan 2023 03:23:23 -0800 (PST) MIME-Version: 1.0 References: <70bdc2f9-f0ae-cca7-0910-859cacbf5eae.ref@yahoo.co.jp> <70bdc2f9-f0ae-cca7-0910-859cacbf5eae@yahoo.co.jp> In-Reply-To: <70bdc2f9-f0ae-cca7-0910-859cacbf5eae@yahoo.co.jp> From: Max Filippov Date: Tue, 17 Jan 2023 03:23:12 -0800 Message-ID: Subject: Re: [PATCH v2] xtensa: Eliminate the use of callee-saved register that saves and restores only once To: "Takayuki 'January June' Suwa" Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Suwa-san, On Mon, Jan 16, 2023 at 8:12 PM Takayuki 'January June' Suwa wrote: > > In the case of the CALL0 ABI, values that must be retained before and > after function calls are placed in the callee-saved registers (A12 > through A15) and referenced later. However, it is often the case that > the save and the reference are each only once and a simple register- > register move (the frame pointer is needed to recover the stack pointer > and must be excluded). > > e.g. in the following example, if there are no other occurrences of > register A14: > > ;; before > ; prologue { > ... > s32i.n a14, sp, 16 > ... > ; } prologue > ... > mov.n a14, a6 > ... > call0 foo > ... > mov.n a8, a14 > ... > ; epilogue { > ... > l32i.n a14, sp, 16 > ... > ; } epilogue > > It can be possible like this: > > ;; after > ; prologue { > ... > (deleted) > ... > ; } prologue > ... > s32i.n a6, sp, 16 > ... > call0 foo > ... > l32i.n a8, sp, 16 > ... > ; epilogue { > ... > (deleted) > ... > ; } epilogue > > This patch introduces a new peephole2 pattern that implements the above. > > gcc/ChangeLog: > > * config/xtensa/xtensa.md: New peephole2 pattern that eliminates > the use of callee-saved register that saves and restores only once > for other register, by using its stack slot directly. > --- > gcc/config/xtensa/xtensa.md | 60 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 60 insertions(+) There's still a few regressions in tests with -fcompare-debug because code generated with -g and without it is different: +FAIL: gcc.dg/pr41241.c (test for excess errors) +FAIL: gcc.dg/pr48159-1.c (test for excess errors) +FAIL: gcc.dg/pr65521.c (test for excess errors) +FAIL: gcc.dg/torture/pr42878-1.c -O2 (test for excess errors) +FAIL: gcc.dg/torture/pr42878-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) +FAIL: gcc.dg/torture/pr42878-1.c -O3 -g (test for excess errors) +FAIL: gcc.dg/torture/pr42878-1.c -Os (test for excess errors) +FAIL: gcc.dg/torture/pr42878-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) E.g. check the following test with -g0 and -g: gcc/cc1 gcc/testsuite/gcc.dg/torture/pr42878-1.c -mlongcalls -mtext-section-literals -fdiagnostics-plain-output -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions -- Thanks. -- Max