From patchwork Thu May 28 08:52:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiufu Guo X-Patchwork-Id: 1299576 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=BsF5peaL; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49XhKW42tBz9sSc for ; Thu, 28 May 2020 18:52:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C340A395C038; Thu, 28 May 2020 08:52:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C340A395C038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1590655941; bh=9CJ6G5vb8E01ViIb9WdEmxT9de3bGbg8WdkYFagj1GI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=BsF5peaLUcnXA2FXaMg6um7Vb+MmBbcNJuPhfBaVmwIWL/xeo7SkMKvWuol+omMwE YsN/lWiGBJB+B03IHWNWEC37BFNDeGsH0nszIj02VAQ4ElkpQdptSQew7dq9zP86R9 mW81e0F0HwsvXA+61j4fGaMRhG/10xfamM+vQpT4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id C4C71389040A for ; Thu, 28 May 2020 08:52:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C4C71389040A Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04S8WqYc052087; Thu, 28 May 2020 04:52:17 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 316ygd3k2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 May 2020 04:52:17 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04S8WssX052343; Thu, 28 May 2020 04:52:17 -0400 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 316ygd3k1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 May 2020 04:52:17 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 04S8jbtH005179; Thu, 28 May 2020 08:52:13 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma02fra.de.ibm.com with ESMTP id 316uf8uw2y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 May 2020 08:52:13 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04S8qBPA9437462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 May 2020 08:52:11 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D80AF11C05E; Thu, 28 May 2020 08:52:10 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE18511C06E; Thu, 28 May 2020 08:52:09 +0000 (GMT) Received: from genoa.aus.stglabs.ibm.com (unknown [9.40.192.157]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 28 May 2020 08:52:09 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] Introduce flag_cunroll_grow_size for cunroll Date: Thu, 28 May 2020 16:52:06 +0800 Message-Id: <20200528085207.4021-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-05-28_02:2020-05-28, 2020-05-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 cotscore=-2147483648 spamscore=0 lowpriorityscore=0 suspectscore=1 bulkscore=0 mlxlogscore=852 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005280057 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: guojiufu via Gcc-patches From: Jiufu Guo Reply-To: guojiufu Cc: wschmidt@linux.ibm.com, dje.gcc@gmail.com, segher@kernel.crashing.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" From: Jiufu Guo Currently GIMPLE complete unroller(cunroll) is checking flag_unroll_loops and flag_peel_loops to see if allow size growth. Beside affects curnoll, flag_unroll_loops also controls RTL unroler. To have more freedom to control cunroll and RTL unroller, this patch introduces flag_cunroll_grow_size. With this patch, we can control cunroll and RTL unroller indepently. Bootstrap/regtest pass on powerpc64le. OK for trunk? And backport to GCC10 after week? gcc/ChangeLog 2020-02-28 Jiufu Guo * common.opt (flag_cunroll_grow_size): New flag. * toplev.c (process_options): Set flag_cunroll_grow_size. * tree-ssa-loop-ivcanon.c (pass_complete_unroll::execute): Use flag_cunroll_grow_size. --- gcc/common.opt | 4 ++++ gcc/toplev.c | 4 ++++ gcc/tree-ssa-loop-ivcanon.c | 3 +-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 4464049fc1f..1d0fa7b1749 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2856,6 +2856,10 @@ funroll-all-loops Common Report Var(flag_unroll_all_loops) Optimization Perform loop unrolling for all loops. +funroll-completely-grow-size +Var(flag_cunroll_grow_size) Init(2) +; Control cunroll to allow size growth during complete unrolling + ; Nonzero means that loop optimizer may assume that the induction variables ; that control loops do not overflow and that the loops with nontrivial ; exit condition are not infinite diff --git a/gcc/toplev.c b/gcc/toplev.c index 96316fbd23b..8d52358efdd 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1474,6 +1474,10 @@ process_options (void) if (flag_unroll_all_loops) flag_unroll_loops = 1; + /* Allow cunroll to grow size accordingly. */ + if (flag_cunroll_grow_size == AUTODETECT_VALUE) + flag_cunroll_grow_size = flag_unroll_loops || flag_peel_loops; + /* web and rename-registers help when run after loop unrolling. */ if (flag_web == AUTODETECT_VALUE) flag_web = flag_unroll_loops; diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 8ab6ab3330c..d6a4617a6a1 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -1603,8 +1603,7 @@ pass_complete_unroll::execute (function *fun) re-peeling the same loop multiple times. */ if (flag_peel_loops) peeled_loops = BITMAP_ALLOC (NULL); - unsigned int val = tree_unroll_loops_completely (flag_unroll_loops - || flag_peel_loops + unsigned int val = tree_unroll_loops_completely (flag_cunroll_grow_size || optimize >= 3, true); if (peeled_loops) {