From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by sourceware.org (Postfix) with ESMTPS id 7BC9B3858422 for ; Wed, 18 Jan 2023 09:04:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BC9B3858422 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-yb1-xb35.google.com with SMTP id e130so7825313yba.7 for ; Wed, 18 Jan 2023 01:04:57 -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=STfyoHm22MqVnfi5rfv0kv0AGxGDglIeWY735tTYijw=; b=HtvJY0pitLUUBuMi5ZMhnXG2s19fX7YqkBfis61Hq56XtMQpIo/4FqyHqmpqx1PltO gPac/aQ4lgRkYeejJdeuLK4BN10TnfR5JimdXRWeAbECZrqjdWwh0jSVW5C/mO4Lfx6l JaTpbFYbBb3qtJ2zmEgalMsgpzAc3RENcWHFsi846mQzET0NSAaBf/t+NYjcjVd9fBbV 1s3ahrLVnVYjTWwgNgsTLzfeuwpzQ5gXV19537VXonViIGWzC5A+KI36jTGEUuScxTvb 9Rda+Tl1PyuLtDUn8MslZe6XDB6pC9lW+v0XVj+wu6hnr5W3X0S/jonL5UazkqnGbttZ hCAQ== 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=STfyoHm22MqVnfi5rfv0kv0AGxGDglIeWY735tTYijw=; b=m0Dco0C+LFfzENDxD3yz4+zV7ynro5JriI8i2EHtcA4p64PAUAWa9UavM86Tupq+az lU2FFUwiEAuU3kIg+LhUM54rc1MNgb2b/K/ZM0RmuxoNID6wbw5p6hkcVZ4Loa3PVhP+ SrFWC+zPBshwO9AdpTbkCyQEXVL4tORSSu4Pi3hjl2hqG0JzUVOUYQzuQLJscAbKH1lU bqbHJ+/YGUmRy1Z++zGDQsuFwSKE/xRWP0xl6UODNHjOhqffVdDx5GqI8g++1qm7fL/9 5ZGekcDJ8Lo0BtDEg9KQne09hRmvnNWlDjfYidblEVEF4pC13RTu1NvJ1GaryL9EYaSk IGAg== X-Gm-Message-State: AFqh2kr1pCFr5KkLuU3fw06BcyMvb2L8xRK3huWm0zU2HPQxH59W3oTg 4+wJ6ZaDxEmBwzor8UEZw5YO/cO7vFtAqgdu0hmpUMhM6gY= X-Google-Smtp-Source: AMrXdXs3ZLQzY0CDIGhZz2tjqZ3kPIhWCYeiLdEuxZAdn6oluwTKLyOY3WOaLFrTI3wagRJsvOcRKskmwRIUFS7/xAc= X-Received: by 2002:a25:5187:0:b0:7f7:6bba:b530 with SMTP id f129-20020a255187000000b007f76bbab530mr74786ybb.377.1674032696752; Wed, 18 Jan 2023 01:04:56 -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: From: Max Filippov Date: Wed, 18 Jan 2023 01:04:45 -0800 Message-ID: Subject: Re: [PATCH v3] 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.7 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 Tue, Jan 17, 2023 at 8:23 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 | 62 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 62 insertions(+) This change introduces a bunch of different test failures: FAIL: gcc.c-torture/execute/builtins/strpbrk.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/strpbrk.c execution, -O3 -g FAIL: gcc.c-torture/execute/builtins/strpbrk.c execution, -Os FAIL: gcc.c-torture/execute/builtins/strpbrk.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/strstr-asm.c execution, -Os FAIL: gcc.c-torture/execute/20001130-1.c -Os execution test FAIL: gcc.c-torture/execute/20040311-1.c -O2 execution test FAIL: gcc.c-torture/execute/20040311-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20040311-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20121108-1.c -O2 execution test FAIL: gcc.c-torture/execute/20121108-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.c-torture/execute/20121108-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20121108-1.c -Os execution test FAIL: gcc.c-torture/execute/20121108-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20121108-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/20140622-1.c -O2 execution test FAIL: gcc.c-torture/execute/20140622-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20140622-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20141022-1.c -O2 execution test FAIL: gcc.c-torture/execute/20141022-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.c-torture/execute/20141022-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20141022-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20141022-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/20141107-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/961213-1.c -Os execution test FAIL: gcc.c-torture/execute/builtin-bitops-1.c -Os execution test FAIL: gcc.c-torture/execute/cvt-1.c -O2 execution test FAIL: gcc.c-torture/execute/cvt-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/cvt-1.c -Os execution test FAIL: gcc.c-torture/execute/cvt-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr40747.c -O2 execution test FAIL: gcc.c-torture/execute/pr40747.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr40747.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr60960.c -O2 execution test FAIL: gcc.c-torture/execute/pr60960.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr60960.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr60960.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/ieee/fp-cmp-5.c execution, -O2 FAIL: gcc.c-torture/execute/ieee/fp-cmp-5.c execution, -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions FAIL: gcc.c-torture/execute/ieee/fp-cmp-5.c execution, -O3 -g FAIL: gcc.c-torture/execute/ieee/fp-cmp-5.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/ieee/fp-cmp-5.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects FAIL: gcc.dg/pr103721.c execution test FAIL: gcc.dg/pr38364.c execution test FAIL: gcc.dg/pr92301.c execution test FAIL: gcc.dg/strlenopt-92.c execution test FAIL: gcc.dg/torture/pr90553.c -O2 execution test FAIL: gcc.dg/torture/pr90553.c -O3 -g execution test FAIL: gcc.dg/torture/pr90553.c -Os execution test FAIL: gcc.dg/torture/pr90553.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/torture/pr90553.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.dg/torture/stackalign/vararg-1.c -O2 execution test FAIL: gcc.dg/torture/stackalign/vararg-1.c -O2 -fpic execution test FAIL: gcc.dg/torture/stackalign/vararg-1.c -O3 -g execution test FAIL: gcc.dg/torture/stackalign/vararg-1.c -O3 -g -fpic execution test FAIL: gcc.dg/torture/stackalign/vararg-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/torture/stackalign/vararg-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none -fpic execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -O2 execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -O3 -g execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -Os execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -O2 -fpic execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -O3 -g -fpic execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -Os -fpic execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -O2 -fPIC execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -O3 -g -fPIC execution test FAIL: gcc.dg/torture/tls/thr-init-2.c -Os -fPIC execution test -- Thanks. -- Max