From patchwork Wed Nov 16 23:54:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyu Wang X-Patchwork-Id: 21343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp123475wrr; Wed, 16 Nov 2022 15:57:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ygmkVnYuzyL18QpYuhVSHJHswDOgqnlFkxTZ6V85RRkfknboew5YzbuM7oFsnwPnwbwjU X-Received: by 2002:a17:906:1f02:b0:78d:d2e5:7a11 with SMTP id w2-20020a1709061f0200b0078dd2e57a11mr161287ejj.144.1668643043620; Wed, 16 Nov 2022 15:57:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668643043; cv=none; d=google.com; s=arc-20160816; b=wopOZHnuP4xnt4UNlPDO/OCcPBLAskuNjzEHTwAainV2Cf4ahShhhdOSfxrNARf6EY FfsPLOIa+mP9Qlt8md5Z2TNaClQoslCJmdAvowCKVdwml2t6/kWMNBgGe56Vbd23u8hH BVomnHRUs1uTzIoKgPAOOjRp+A3CO7dyeTJs5qWr5X6GY08BaSK96FDZLbMGDsfklUYE Kyt2B5N5ybF29ggdOfy+Sf9K2zlOQdc9Bs+MInLG7usqnxaIqP+5LiMgPw70GF8lisEx 1hcCz/UsP+vKf/C7cPG3cqYij6nn3yP8ZgMxk922NCsAUVMt9wAZeyVV3kY1GcKSVx/o o4Uw== 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:message-id:date :subject:cc:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Z2wGEKHjb1Wq4RuplMZD3QJoyAH5KGzTXpMo9NbmFjM=; b=QCjIbcPF5nYNdt9efkRo5bkYEGRiWn4AohB6GaKHJburbjXeBc12fOz8OaPmYj2FLx r1ICZQZwD51cNFrt5H9xeHNSwmh+LeIvToMUtExQIhKJSBErlUuvobf0KfBP+TC3ACz+ PUvVsJb368KvnxfdnPlGg3RSZB1RDSJnmyXeWgAHbmseYHFfipf4Rf6+ZWPsKJ19WH5e AmmbmcGF5lc77aBYMHgucQykNJdanwPrxDXRbVsnq4g9CNNCrhvQcquZZs72o/aKKe9x uC90NdHqnMInxinG3FYIDr0eZH8Qbx51t32wtaUup+7VaZq0XNC7TyyTyEZAzFohjJVZ y1TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=u8GYvz8q; 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 g11-20020a056402090b00b00468310367c5si6202585edz.214.2022.11.16.15.57.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:57:23 -0800 (PST) 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=u8GYvz8q; 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 61393396E45E for ; Wed, 16 Nov 2022 23:57:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61393396E45E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668643042; bh=Z2wGEKHjb1Wq4RuplMZD3QJoyAH5KGzTXpMo9NbmFjM=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=u8GYvz8qinqbLNQNQaMEd0Xrpna9Yicz/27TatUnvuSD+ofose+ne9mOqyXXr5Mfz 66iVrRomz0yxTnSXaCpQ+eVjcxTXmHCtiXnXAmHayiO47ZVvnFBQiY8bIeTHnYX3hy oMg/Xki+HOaJa6zjpwiLGBfncwSE0lxKPBNlLUlE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 124C6396E073 for ; Wed, 16 Nov 2022 23:56:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 124C6396E073 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="398989070" X-IronPort-AV: E=Sophos;i="5.96,169,1665471600"; d="scan'208";a="398989070" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2022 15:56:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="745274821" X-IronPort-AV: E=Sophos;i="5.96,169,1665471600"; d="scan'208";a="745274821" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga002.fm.intel.com with ESMTP; 16 Nov 2022 15:56:30 -0800 Received: from shliclel320.sh.intel.com (shliclel320.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 663B6100571A; Thu, 17 Nov 2022 07:56:29 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com Subject: [PATCH] rs6000: Adjust loop_unroll_adjust to match middle-end change [PR 107692] Date: Thu, 17 Nov 2022 07:54:29 +0800 Message-Id: <20221116235429.25268-1-hongyu.wang@intel.com> X-Mailer: git-send-email 2.18.1 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE, SPF_SOFTFAIL, 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: Hongyu Wang via Gcc-patches From: Hongyu Wang Reply-To: Hongyu Wang Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749699048152655177?= X-GMAIL-MSGID: =?utf-8?q?1749699048152655177?= Hi, r13-3950-g071e428c24ee8c enables O2 small loop unrolling, but it breaks -fno-unroll-loops for rs6000 with loop_unroll_adjust hook. Adjust the option handling and target hook accordingly. Bootstrapped & regtested on powerpc64le-linux-gnu, OK for trunk? gcc/ChangeLog: PR target/107692 * common/config/rs6000/rs6000-common.cc: Do not enable funroll-loops by default. * config/rs6000/rs6000.cc (rs6000_override_options_after_change): Remove flag override about loop unroll. (rs6000_loop_unroll_adjust): Turns off munroll-only-small-loops when explicit -f[no-]unroll-[all-]loops is set. --- gcc/common/config/rs6000/rs6000-common.cc | 6 +-- gcc/config/rs6000/rs6000.cc | 45 ++++++++++------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/gcc/common/config/rs6000/rs6000-common.cc b/gcc/common/config/rs6000/rs6000-common.cc index 8e393d08a23..7186d0c309c 100644 --- a/gcc/common/config/rs6000/rs6000-common.cc +++ b/gcc/common/config/rs6000/rs6000-common.cc @@ -34,9 +34,9 @@ static const struct default_options rs6000_option_optimization_table[] = { OPT_LEVELS_ALL, OPT_fsplit_wide_types_early, NULL, 1 }, /* Enable -fsched-pressure for first pass instruction scheduling. */ { OPT_LEVELS_1_PLUS, OPT_fsched_pressure, NULL, 1 }, - /* Enable -munroll-only-small-loops with -funroll-loops to unroll small - loops at -O2 and above by default. */ - { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_funroll_loops, NULL, 1 }, + + /* Enable -munroll-only-small-loops to unroll small loops at -O2 and + above by default. */ { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_munroll_only_small_loops, NULL, 1 }, /* -frename-registers leads to non-optimal codegen and performance diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index a85d7630b41..26e41b4b3b0 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -3392,22 +3392,6 @@ rs6000_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, static void rs6000_override_options_after_change (void) { - /* Explicit -funroll-loops turns -munroll-only-small-loops off, and - turns -frename-registers on. */ - if ((OPTION_SET_P (flag_unroll_loops) && flag_unroll_loops) - || (OPTION_SET_P (flag_unroll_all_loops) - && flag_unroll_all_loops)) - { - if (!OPTION_SET_P (unroll_only_small_loops)) - unroll_only_small_loops = 0; - if (!OPTION_SET_P (flag_rename_registers)) - flag_rename_registers = 1; - if (!OPTION_SET_P (flag_cunroll_grow_size)) - flag_cunroll_grow_size = 1; - } - else if (!OPTION_SET_P (flag_cunroll_grow_size)) - flag_cunroll_grow_size = flag_peel_loops || optimize >= 3; - /* If we are inserting ROP-protect instructions, disable shrink wrap. */ if (rs6000_rop_protect) flag_shrink_wrap = 0; @@ -5540,17 +5524,26 @@ rs6000_cost_data::finish_cost (const vector_costs *scalar_costs) static unsigned rs6000_loop_unroll_adjust (unsigned nunroll, struct loop *loop) { - if (unroll_only_small_loops) - { - /* TODO: These are hardcoded values right now. We probably should use - a PARAM here. */ - if (loop->ninsns <= 6) - return MIN (4, nunroll); - if (loop->ninsns <= 10) - return MIN (2, nunroll); + if (!(flag_unroll_loops || flag_unroll_all_loops + || loop->unroll)) + { + unsigned nunroll_orig = nunroll; + nunroll = 1; + /* Any explicit -f{no-}unroll-{all-}loops turns off + -munroll-only-small-loops. */ + if (unroll_only_small_loops + && !OPTION_SET_P (flag_unroll_loops)) + { + /* TODO: These are hardcoded values right now. We probably should use + a PARAM here. */ + if (loop->ninsns <= 6) + return MIN (4, nunroll_orig); + if (loop->ninsns <= 10) + return MIN (2, nunroll_orig); - return 0; - } + return 0; + } + } return nunroll; }