From patchwork Wed Nov 13 13:13:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 1194250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513239-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="e/wz7dve"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47ClSJ2rD5z9sPZ for ; Thu, 14 Nov 2019 00:14:06 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=IJupNhI0TQqRYyNcN 0hGc7ghWYHYbYC9OPopClkhjhWDLIVEvyfbH10MpO6oc481S15SK/1F9E7MyCuPx +pKveakBByWBGaszl//94quPNof+Nfqpg3BdNYJHcx91gdXlQxkHzEmArgnEkIgA Kb3Oj4oGyVY5ChYP7tH0yYusAM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=nHRVmV5KEskUO5NkhkYvzh/ 3Ud0=; b=e/wz7dveYagKokojHEom7+z53Hn45S/3YuOkcGpRV9Ti6u+CpFZydFn l+HPhgpgtr+KwwP58We4/wsI1cjU5IfW/1TbPyF+SSf/EMkvc0kgckh51MehpIDw YXX+tSvlt4qh8vlFZ9EIuewOREqh05XDTS5PS6WqzeddyRe9RfZQ= Received: (qmail 129704 invoked by alias); 13 Nov 2019 13:13:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 129694 invoked by uid 89); 13 Nov 2019 13:13:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*r:sk:mailout, H*RU:sk:mailout, HX-Spam-Relays-External:sk:mailout X-HELO: mailout01.t-online.de Received: from mailout01.t-online.de (HELO mailout01.t-online.de) (194.25.134.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2019 13:13:57 +0000 Received: from fwd35.aul.t-online.de (fwd35.aul.t-online.de [172.20.27.145]) by mailout01.t-online.de (Postfix) with SMTP id 010CB42366B3 for ; Wed, 13 Nov 2019 14:13:55 +0100 (CET) Received: from sweetums.local (T5dEo4ZYrhLR3EIT4t9H0vs7DYuCEZ1iLMaYipYc7UUD0O-IiD84vYNW3rCdczLQCI@[84.128.94.135]) by fwd35.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iUsT3-1hfjGa0; Wed, 13 Nov 2019 14:13:53 +0100 Subject: [PATCH 3/4] Set costs for jumps in combine From: Bernd Schmidt To: GCC Patches References: Openpgp: preference=signencrypt Message-ID: Date: Wed, 13 Nov 2019 14:13:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes The combiner is somewhat strange about how it uses costs. If any of the insns involved in a comparison have a cost of 0, it does not verify that the substitution is cheaper. Also, it does not compute costs for jump insns, so they are always set to zero. As a consequence, any possible substitution is performed if a combination into a jump is possible, which turns out isn't really desirable on m68k with cbranch patterns. This patch simply removes a test for NONJUMP_INSN_P. Bootstrapped and tested on the gcc135 machine (powerpc64le-unknown-linux-gnu). Bernd * combine.c (combine_instructions): Record costs for jumps. diff --git a/gcc/combine.c b/gcc/combine.c index 857ea30dafd..9446d2769ab 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -1234,8 +1234,7 @@ combine_instructions (rtx_insn *f, unsigned int nregs) insn); /* Record the current insn_cost of this instruction. */ - if (NONJUMP_INSN_P (insn)) - INSN_COST (insn) = insn_cost (insn, optimize_this_for_speed_p); + INSN_COST (insn) = insn_cost (insn, optimize_this_for_speed_p); if (dump_file) { fprintf (dump_file, "insn_cost %d for ", INSN_COST (insn)); From patchwork Wed Nov 13 13:21:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 1194253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513240-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Y1bgiHTG"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Clcb6vt6z9sPc for ; Thu, 14 Nov 2019 00:21:18 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=L7VWr5lg+pjk8BefZ tONzX13GHjUcSTpTT+bASetn3yWuSlNNG0NUfmtns443E6fNHdxLVsV12eeElGEb 48Qt0+xneDgHUB539uHesQTLHdnXKNU3BZGkF+pzbhrIsxcJuBVm9h1Jg+bHds2/ u6yD+bVhCB1ysWhDtbPZEeE7BI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=U8E7JZ7w01kGtkqWa7OlxVg ZQK0=; b=Y1bgiHTGoSv8jsSdHM4RTdFxUIPL0u+vsYQhxD9+qkU+ytLWgYS0DeD ZEUXHiT85vTx51OuW2gFAomiIxl/RVkU8iIazSo9x9NwjkS7EWSJ1C9h6JOfaxSW 5UWE71+SqoXHn/F0S+W0abiDDhytCb3E3tJBV3RjPnh0o+21VADM= Received: (qmail 11876 invoked by alias); 13 Nov 2019 13:21:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11866 invoked by uid 89); 13 Nov 2019 13:21:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=basic_block, quality, H*r:sk:mailout, H*RU:sk:mailout X-HELO: mailout10.t-online.de Received: from mailout10.t-online.de (HELO mailout10.t-online.de) (194.25.134.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2019 13:21:09 +0000 Received: from fwd11.aul.t-online.de (fwd11.aul.t-online.de [172.20.27.152]) by mailout10.t-online.de (Postfix) with SMTP id C7D8A41BA1F4 for ; Wed, 13 Nov 2019 14:21:06 +0100 (CET) Received: from sweetums.local (TzfmkeZbwhx1bf2KFZBDAyTdg0Bs6PrfYmMkI7BIynAiEv+9-areQtxubsPMSKUQRW@[84.128.94.135]) by fwd11.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iUsa2-0AKz0C0; Wed, 13 Nov 2019 14:21:06 +0100 Subject: [PATCH 4/4] Fix autoinc cbranch From: Bernd Schmidt To: GCC Patches References: Openpgp: preference=signencrypt Message-ID: <3b41f42c-188e-7afb-7554-e43971aa1c96@t-online.de> Date: Wed, 13 Nov 2019 14:21:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes After the m68k cc0 conversion, there is one code quality regression that I can see: we no longer generate autoinc addressing modes in comparisons. This is because the parts of the compiler that generate autoinc are unwilling to substitute into jumps. If you look at the code in reload, you'll see that it's careful around jumps at find_reload time, and the code to perform autoinc reloads does try to put all the extra code before the instruction. LRA seems to have copied most of that code. Also, in the former cc0 reality, a compare wasn't really any different from a jump on m68k: we can't have a reload after the instruction in either case. Any kind of move or arithmetic would clobber the flags. That leads me to believe that there is no issue with autoinc in jumps, hence this patch. Bootstrapped and tested on the gcc135 machine (powerpc64le-unknown-linux-gnu). I don't really expect this to get approved; alternatively I could write some peepholes which would generate the same code as long as register pressure doesn't get too high. Bernd * auto-inc-dec.c (merge_in_block): Allow jumps. * combine.c (can_combine_p): Allow jumps in autoinc. diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c index bdb6efa..6dab135 100644 --- a/gcc/auto-inc-dec.c +++ b/gcc/auto-inc-dec.c @@ -1441,10 +1441,11 @@ merge_in_block (int max_reg, basic_block bb) continue; } - /* This continue is deliberate. We do not want the uses of the - jump put into reg_next_use because it is not considered safe to - combine a preincrement with a jump. */ - if (JUMP_P (insn)) + /* We used to skip jump insns, but both reload and LRA seem to + take precautions not to perform autoinc reloads after a jump or + a comparison. Allow them for regular autoinc only (for test + coverage reasons more than anything). */ + if ((HAVE_PRE_MODIFY_REG || HAVE_POST_MODIFY_REG) && JUMP_P (insn)) continue; if (dump_file) diff --git a/gcc/combine.c b/gcc/combine.c index 857ea30..e9e1464 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -2119,15 +2118,12 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_insn *pred ATTRIBUTE_UNUSED, /* If INSN contains an autoincrement or autodecrement, make sure that register is not used between there and I3, and not already used in - I3 either. Neither must it be used in PRED or SUCC, if they exist. - Also insist that I3 not be a jump; if it were one - and the incremented register were spilled, we would lose. */ + I3 either. Neither must it be used in PRED or SUCC, if they exist. */ if (AUTO_INC_DEC) for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) if (REG_NOTE_KIND (link) == REG_INC - && (JUMP_P (i3) - || reg_used_between_p (XEXP (link, 0), insn, i3) + && (reg_used_between_p (XEXP (link, 0), insn, i3) || (pred != NULL_RTX && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred))) || (pred2 != NULL_RTX