From patchwork Wed May 31 01:35:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 101179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2575869vqr; Tue, 30 May 2023 18:36:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ60BstoYHAs+JzhOcGJejl2ev7kpWxaAmVMFqpk57kMmxtJ0XdzS0/Jmqb5nc+naRKIqcxk X-Received: by 2002:a50:fb94:0:b0:514:95b1:f0ba with SMTP id e20-20020a50fb94000000b0051495b1f0bamr2342666edq.34.1685496990387; Tue, 30 May 2023 18:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685496990; cv=none; d=google.com; s=arc-20160816; b=jWretCaYH1Y5Z8t5E0l7lIneyK3raRQI82R+ZQHhi0YS1uZRLeG84f17rT5LoeRI/u KK4eJpujFMydTZzMkYleD2Fgh2OcHwEVU0vtnou/gp6wCOfdjicjikj4KCLZRiRnSKLt Je8aav68QPf8ykvazFu6hAhAP7utW5iZ23e3WBJgqjZYAMwhGan9WeQ+CeD8kxXs/yp1 ZopF+/F5XNatjKYgj44kCoIFw6aJ+YBEd3LX0Loi0lL+nFwGgE8TaavvWmCBzR75bnCQ g40ed/8gQkLg9S5JnF8DcL6d03BZdCUPF3WVYXH6NsA68HlnY2N5aTLoq/P4sLGCmHuM CFOw== 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:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Y/Lu95nH2r8spSaZiJ7dzJyOeFxCHjx4HBATSEwREU4=; b=K42/WaNlz9j3GRUJCRtDzFGB7LLWjFHAck7aHkvIru8Jl7RXR6/u3rpEcRNWjqdRLy xFYhLbgMonmu3oVAF8T7i+SCHSlCMyEz8KdwnhvrkfHD+KR/7jTlbC83JdoKxnLfeyw5 5Hgzg2LmRWuTVcHTBZ44+ZOV6Htv0YftttnoPpm8IZBxOrv5cJ1tfG+KJqXmTpIaL16f Gk+B/YEHB4t93G9XtD657G4XcZAaIxLEe5qh20f5dzVRvac8t4+ZC4f/dW7hSsexycKN FJ6Oamvc1SHXUPyxLEP5UjjZRB1tOFXjQDnFU50Ia8Cb6cDnfXwyNlYGFp9Um63wpkFq uJYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tH0vvXyk; 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 o21-20020aa7c515000000b0050c1724bce8si7703642edq.312.2023.05.30.18.36.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 18:36:30 -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=tH0vvXyk; 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 11ADD385840C for ; Wed, 31 May 2023 01:36:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11ADD385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685496989; bh=Y/Lu95nH2r8spSaZiJ7dzJyOeFxCHjx4HBATSEwREU4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=tH0vvXykL8ECi/MTjOKV0Z8ev5QZ5xZ0BR1YIwL7LxkMsOOodZJgsc+70OGNfawMn yiewNnmVp9z1Pr+uZ5ntugotuNrU08+52wSLn0JydMDPp/Ucid7iHhuVtiJ+Xk3aq1 2irf4kmUfN/qPpthqnQ596d57Sym8hnB758bd8Fs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id C83F93858D20 for ; Wed, 31 May 2023 01:35:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C83F93858D20 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="420862172" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="420862172" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 18:35:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="851025237" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="851025237" Received: from scymds03.sc.intel.com ([10.148.94.166]) by fmsmga001.fm.intel.com with ESMTP; 30 May 2023 18:35:27 -0700 Received: from shgcc101.sh.intel.com (shgcc101.sh.intel.com [10.239.85.97]) by scymds03.sc.intel.com (Postfix) with ESMTP id 1F64464; Tue, 30 May 2023 18:35:26 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com Subject: [PATCH] Fix ICE in rewrite_expr_tree_parallel Date: Wed, 31 May 2023 01:35:25 +0000 Message-Id: <20230531013525.4133283-1-lili.cui@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Cui, Lili via Gcc-patches" From: "Li, Pan2 via Gcc-patches" Reply-To: "Cui, Lili" 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?1767371692025878792?= X-GMAIL-MSGID: =?utf-8?q?1767371692025878792?= Hi, This patch is to fix ICE in rewrite_expr_tree_parallel. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110038 Bootstrapped and regtested. Ok for trunk? Regards Lili. 1. Limit the value of tree-reassoc-width to IntegerRange(0, 256). 2. Add width limit in rewrite_expr_tree_parallel. gcc/ChangeLog: PR tree-optimization/110038 * params.opt: Add a limit on tree-reassoc-width. * tree-ssa-reassoc.cc (rewrite_expr_tree_parallel): Add width limit. gcc/testsuite/ChangeLog: PR tree-optimization/110038 * gcc.dg/pr110038.c: New test. --- gcc/params.opt | 2 +- gcc/testsuite/gcc.dg/pr110038.c | 10 ++++++++++ gcc/tree-ssa-reassoc.cc | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr110038.c diff --git a/gcc/params.opt b/gcc/params.opt index 66f1c99036a..70cfb495e3a 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -1091,7 +1091,7 @@ Common Joined UInteger Var(param_tracer_min_branch_ratio) Init(10) IntegerRange( Stop reverse growth if the reverse probability of best edge is less than this threshold (in percent). -param=tree-reassoc-width= -Common Joined UInteger Var(param_tree_reassoc_width) Param Optimization +Common Joined UInteger Var(param_tree_reassoc_width) IntegerRange(0, 256) Param Optimization Set the maximum number of instructions executed in parallel in reassociated tree. If 0, use the target dependent heuristic. -param=tsan-distinguish-volatile= diff --git a/gcc/testsuite/gcc.dg/pr110038.c b/gcc/testsuite/gcc.dg/pr110038.c new file mode 100644 index 00000000000..0f578b182ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110038.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O --param=tree-reassoc-width=256" } */ + +unsigned a, b; + +void +foo (unsigned c) +{ + a += b + c + 1; +} diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc index ad2f528ff07..f8055d59d57 100644 --- a/gcc/tree-ssa-reassoc.cc +++ b/gcc/tree-ssa-reassoc.cc @@ -5510,6 +5510,9 @@ rewrite_expr_tree_parallel (gassign *stmt, int width, bool has_fma, for (i = stmt_num - 2; i >= 0; i--) stmts[i] = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmts[i+1])); + /* Width should not be larger than op_num/2. */ + width = width <= op_num / 2 ? width : op_num / 2; + /* Build parallel dependency chain according to width. */ for (i = 0; i < width; i++) {