From patchwork Fri Jul 30 11:15:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1511618 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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=Dy/cv9GJ; 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 4GblG96btFz9sXk for ; Fri, 30 Jul 2021 21:16:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05C6C39450E5 for ; Fri, 30 Jul 2021 11:16:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05C6C39450E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643791; bh=h/XcOusny4QfJQa2AgRvst2bWfUvfKXXABnAwM+aPPA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Dy/cv9GJa1zcc6FVFkR2OVypL+EMDgkM7iwoQaMeF6LFPlSsSe1lJjtYeIU6VhhJY mazqBJWGIptEagqWoQ8CJq0lHy9nRHx97GSCKskzyc95LSOvX+pkaz2qsrEf/dojbp CM9WxnHLHzq0qbs3gbP1172TEeiDUs5ldDul1qMU= 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 298FD3945C3A for ; Fri, 30 Jul 2021 11:15:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 298FD3945C3A Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16UB3prd177771; Fri, 30 Jul 2021 07:15:51 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3a4fm71dac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jul 2021 07:15:51 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 16UB4lgN181050; Fri, 30 Jul 2021 07:15:50 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3a4fm71d8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jul 2021 07:15:50 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16UBDF6c013764; Fri, 30 Jul 2021 11:15:48 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 3a235kjyu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jul 2021 11:15:47 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16UBFjnB20316590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Jul 2021 11:15:45 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36D66AE087; Fri, 30 Jul 2021 11:15:45 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D0BAAE07D; Fri, 30 Jul 2021 11:15:43 +0000 (GMT) Received: from KewenLins-MacBook-Pro.local (unknown [9.200.47.123]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 30 Jul 2021 11:15:43 +0000 (GMT) To: GCC Patches Subject: [PATCH] Fix typos in move_sese_region_to_fn Message-ID: <08a87e0d-4091-03c9-db2c-cf8686525d10@linux.ibm.com> Date: Fri, 30 Jul 2021 19:15:39 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 9XMJ9_9aV9foKeo0w6Y0YvjF_u0WBVBs X-Proofpoint-GUID: YPXf9nZkq8z8izmxEovmL2YJfCD0l9P_ X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-30_05:2021-07-30, 2021-07-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107300069 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Cc: Jakub Jelinek , Thomas Schwinge Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch is to fix the typos in the move_sese_region_to_fn. As mentioned here [1], I tried to debug the test case gcc.dg/graphite/pr83359.c with trunk, but I found it didn't go into the hunk guard with "if (moved_orig_loop_num)". So I switched to commit 555758de90074 (also reproduced the ICE with 555758de90074~ to ensure my used command step is correct), I noticed the compilation of the test case only covers the hunk else { moved_orig_loop_num[dloop->orig_loop_num] = -1; dloop->orig_loop_num = 0; } it doesn't touch the hunk if ((*larray)[dloop->orig_loop_num] != NULL && get_loop (saved_cfun, dloop->orig_loop_num) == NULL) { if (moved_orig_loop_num[dloop->orig_loop_num] >= 0 && moved_orig_loop_num[dloop->orig_loop_num] < 2) moved_orig_loop_num[dloop->orig_loop_num]++; dloop->orig_loop_num = (*larray)[dloop->orig_loop_num]->num; } so the following hunk using dloop and guarded with "if (moved_orig_loop_num[orig_loop_num] == 2)" doesn't get executed. It explains why the problem doesn't get exposed before. By looking to the code using dloop, I think it's a copy/paste typo, the assertion gcc_assert ((*larray)[dloop->orig_loop_num] != NULL && (get_loop (saved_cfun, dloop->orig_loop_num) == NULL)); would like to ensure the condition in the previous loop iterating is true, that is: if ((*larray)[dloop->orig_loop_num] != NULL && get_loop (saved_cfun, dloop->orig_loop_num) == NULL) But in that context, I think the expected original number has been assigned to variable orig_loop_num by extracting from the arg0 of IFN_LOOP_DIST_ALIAS call. So replace those ones. Is it ok for trunk? [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-July/576367.html BR, Kewen ----- gcc/ChangeLog: * tree-cfg.c (move_sese_region_to_fn): Fix typos on dloop. diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 48ee8c011ab..9883eaaa9bf 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -7747,9 +7747,8 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, /* Fix up orig_loop_num. If the block referenced in it has been moved to dest_cfun, update orig_loop_num field, otherwise clear it. */ - class loop *dloop = NULL; signed char *moved_orig_loop_num = NULL; - for (class loop *dloop : loops_list (dest_cfun, 0)) + for (auto dloop : loops_list (dest_cfun, 0)) if (dloop->orig_loop_num) { if (moved_orig_loop_num == NULL) @@ -7787,11 +7786,10 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, /* If we have moved both loops with this orig_loop_num into dest_cfun and the LOOP_DIST_ALIAS call is being moved there too, update the first argument. */ - gcc_assert ((*larray)[dloop->orig_loop_num] != NULL - && (get_loop (saved_cfun, dloop->orig_loop_num) - == NULL)); + gcc_assert ((*larray)[orig_loop_num] != NULL + && (get_loop (saved_cfun, orig_loop_num) == NULL)); tree t = build_int_cst (integer_type_node, - (*larray)[dloop->orig_loop_num]->num); + (*larray)[orig_loop_num]->num); gimple_call_set_arg (g, 0, t); update_stmt (g); /* Make sure the following loop will not update it. */