Message ID | b67a8fb6-1a83-2806-7472-3f115f302a80@yahoo.co.jp |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp1978174pxh; Tue, 16 Aug 2022 05:43:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR7p87XmCMFKlsrnNg2/1jC29aJjXJL0jpSHAQsNJFrpQHFez7Lqg/M6XTigWoQD4DH+cF0F X-Received: by 2002:a05:6402:369a:b0:43d:75c5:f16c with SMTP id ej26-20020a056402369a00b0043d75c5f16cmr18428919edb.57.1660653785077; Tue, 16 Aug 2022 05:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660653785; cv=none; d=google.com; s=arc-20160816; b=ojkEIGLAyKjFYlqHViUK2H9BiyMoqOOBKEFhYHrGeFI29V6oWhNV87004+gGIpbD7p 7aFPipvMhCJRTZE0RLjsnNQlFHshsJWghMoOgCj0qWTCaVSSIPeXM/k4Beq6iv6NYM+X LOZoY8ruSkmw3KGTdUKH8JC2A4Z1Jih++HgeDT6Yz1EDlKmH4FfmghkM4hNYqZKYKBTZ DYiF14b3MDds9Icw+qeY4TdOPAhEyi2GX04neHKGjrFOpNNHpuGUxZaM1HvhPx/ratf+ yfdorNHUwRwhzzfMukw3HTcqfLEvTyRij8AfJL/tPyLOoJ54qcDwB7ivvT0btIHBrlnt 4vTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:to:user-agent:mime-version:date :message-id:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=dmO0LwZDW6tkgnagBOi7Vbj1AF6CfmLhvg32JSroS3I=; b=iaKJQAYVcDoX9n8ain9e39QNQx4ophw9IJp7MoQ1eoDT5qaGbddmuvWoRSRxoO6m5C vHz19o11qqnGrLHb684S32hsu5tPDd3BbJ/4qGMIUT5fNPHynpJtdKRAagbQ0DdJvPkN iW0ikdC5QOKQsGsvYc8ydEMN3cU9zyHO1SxciH2GLXEFNOTttkQ91CrIwc9z1k+J5wsy WCxva38RE2gj/pH/gEOY3NWJqpgrQjgoLVz0ZnyQVPEeZv007/XC2RpxRhldIukX0ABq TYh4O9uN1ane15cF+PILF86Na82Mfdh+icATmGG79MjBp1aKZ5GZRVyFhuYTDUgx2vai PEtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DOtYXCRW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e16-20020a056402191000b0043e6a689b4bsi12294022edz.536.2022.08.16.05.43.04 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 05:43:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DOtYXCRW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BF0B73858288 for <ouuuleilei@gmail.com>; Tue, 16 Aug 2022 12:43:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF0B73858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660653783; bh=dmO0LwZDW6tkgnagBOi7Vbj1AF6CfmLhvg32JSroS3I=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DOtYXCRWztWdD5Xm+AklahKK9vFPTVLceObVq3+ofK1/b3X11OdsKUnSyBpALl9uA ZTLI9CedOzXGs0n5rUJy0LrRbAg8hrNX3z9snoDBnBGic2n83n4wdyidu5C0XDES4a 7hwicDuVqNzJWnYz8vruiONLMGIsr35Qqqy6n2sI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh602-vm4.bullet.mail.ssk.yahoo.co.jp (nh602-vm4.bullet.mail.ssk.yahoo.co.jp [182.22.90.29]) by sourceware.org (Postfix) with SMTP id 5CD3C385841A for <gcc-patches@gcc.gnu.org>; Tue, 16 Aug 2022 12:42:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5CD3C385841A Received: from [182.22.66.104] by nh602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 16 Aug 2022 12:42:15 -0000 Received: from [182.22.91.129] by t602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 16 Aug 2022 12:42:15 -0000 Received: from [127.0.0.1] by omp602.mail.ssk.yahoo.co.jp with NNFMP; 16 Aug 2022 12:42:15 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 68221.41910.bm@omp602.mail.ssk.yahoo.co.jp Received: (qmail 29872 invoked by alias); 16 Aug 2022 12:42:14 -0000 Received: from unknown (HELO ?192.168.2.3?) (175.177.45.179 with ) by smtp5010.mail.kks.ynwp.y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WwhDpiFfex98yMoIfWJ4uDoNvVIvsNTDW1A68y_PKX.QuvZH2CMI6pQr2N bE74D.CSKggrhON7zkmhU_X4GBmKo3tpUkynQmOKQC4qIf4VjxxZr3RZ2mrL VGiGdVwN9jQ9zY3nC Message-ID: <b67a8fb6-1a83-2806-7472-3f115f302a80@yahoo.co.jp> Date: Tue, 16 Aug 2022 21:40:00 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 To: GCC Patches <gcc-patches@gcc.gnu.org> Subject: [PATCH] xtensa: Prevent emitting integer additions of constant zero Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Takayuki 'January June' Suwa via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1741321703244232167?= X-GMAIL-MSGID: =?utf-8?q?1741321703244232167?= |
Series |
xtensa: Prevent emitting integer additions of constant zero
|
|
Commit Message
Takayuki 'January June' Suwa
Aug. 16, 2022, 12:40 p.m. UTC
In a few cases, obviously omitable add instructions can be emitted via invoking gen_addsi3. gcc/ChangeLog: * config/xtensa/xtensa.md (addsi3_internal): Rename from "addsi3". (addsi3): New define_expand in order to reject integer additions of constant zero. --- gcc/config/xtensa/xtensa.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
Comments
Hi Suwa-san, On Tue, Aug 16, 2022 at 5:42 AM Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp> wrote: > > In a few cases, obviously omitable add instructions can be emitted via > invoking gen_addsi3. > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (addsi3_internal): Rename from "addsi3". > (addsi3): New define_expand in order to reject integer additions of > constant zero. > --- > gcc/config/xtensa/xtensa.md | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) with this change a bunch of tests fail to build with the following error: undefined reference to `__addsi3' E.g. gcc.c-torture/execute/20000519-1.c or gcc.c-torture/execute/20070919-1.c
On 2022/08/17 4:58, Max Filippov wrote: > Hi Suwa-san, Hi! > > On Tue, Aug 16, 2022 at 5:42 AM Takayuki 'January June' Suwa > <jjsuwa_sys3175@yahoo.co.jp> wrote: >> >> In a few cases, obviously omitable add instructions can be emitted via >> invoking gen_addsi3. >> >> gcc/ChangeLog: >> >> * config/xtensa/xtensa.md (addsi3_internal): Rename from "addsi3". >> (addsi3): New define_expand in order to reject integer additions of >> constant zero. >> --- >> gcc/config/xtensa/xtensa.md | 14 +++++++++++++- >> 1 file changed, 13 insertions(+), 1 deletion(-) > > with this change a bunch of tests fail to build with the following error: Ah, sorry, I want to withdraw this patch. >> In a few cases As a matter of fact, "in a few cases" is just only one: [xtensa_expand_epilogue() in /gcc/config/xtensa/xtensa.cc] > if (cfun->machine->current_frame_size > 0) > { > if (frame_pointer_needed || /* always reachable with addi */ > cfun->machine->current_frame_size > 1024 || > cfun->machine->current_frame_size <= 127) > { > if (cfun->machine->current_frame_size <= 127) > offset = cfun->machine->current_frame_size; > else > offset = cfun->machine->callee_save_size; > > emit_insn (gen_addsi3 (stack_pointer_rtx, > stack_pointer_rtx, > GEN_INT (offset))); // offset can be zero! > } And adding "define_expand" only to deal with one rare case had too much impact, as you saw... > undefined reference to `__addsi3' > > E.g. gcc.c-torture/execute/20000519-1.c > or gcc.c-torture/execute/20070919-1.c >
On Wed, Aug 17, 2022 at 2:52 AM Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp> wrote: > As a matter of fact, "in a few cases" is just only one: > > [xtensa_expand_epilogue() in /gcc/config/xtensa/xtensa.cc] > > if (cfun->machine->current_frame_size > 0) > > { > > if (frame_pointer_needed || /* always reachable with addi */ > > cfun->machine->current_frame_size > 1024 || > > cfun->machine->current_frame_size <= 127) > > { > > if (cfun->machine->current_frame_size <= 127) > > offset = cfun->machine->current_frame_size; > > else > > offset = cfun->machine->callee_save_size; > > > > emit_insn (gen_addsi3 (stack_pointer_rtx, > > stack_pointer_rtx, > > GEN_INT (offset))); // offset can be zero! > > } Oh, nice catch! I'll post a patch that adds a check for non-zero offset here.
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 9eeb73915..c132c1626 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -156,7 +156,19 @@ ;; Addition. -(define_insn "addsi3" +(define_expand "addsi3" + [(set (match_operand:SI 0 "register_operand") + (plus:SI (match_operand:SI 1 "register_operand") + (match_operand:SI 2 "add_operand")))] + "" +{ + if (! CONST_INT_P (operands[2]) || INTVAL (operands[2]) != 0) + emit_insn (gen_addsi3_internal (operands[0], + operands[1], operands[2])); + DONE; +}) + +(define_insn "addsi3_internal" [(set (match_operand:SI 0 "register_operand" "=D,D,a,a,a") (plus:SI (match_operand:SI 1 "register_operand" "%d,d,r,r,r") (match_operand:SI 2 "add_operand" "d,O,r,J,N")))]