From patchwork Wed Apr 29 07:16:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhanghaijian (A)" X-Patchwork-Id: 1279027 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=huawei.com 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 49BqZv5R1cz9sSl for ; Wed, 29 Apr 2020 17:17:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7DEC3939C30; Wed, 29 Apr 2020 07:17:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from huawei.com (szxga02-in.huawei.com [45.249.212.188]) by sourceware.org (Postfix) with ESMTPS id 0953A3952000 for ; Wed, 29 Apr 2020 07:17:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0953A3952000 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=z.zhanghaijian@huawei.com Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 0FEC161BCA8E811499F5; Wed, 29 Apr 2020 15:16:54 +0800 (CST) Received: from dggeme714-chm.china.huawei.com (10.1.199.110) by DGGEMM403-HUB.china.huawei.com (10.3.20.211) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 29 Apr 2020 15:16:53 +0800 Received: from dggeme764-chm.china.huawei.com (10.3.19.110) by dggeme714-chm.china.huawei.com (10.1.199.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1913.5; Wed, 29 Apr 2020 15:16:53 +0800 Received: from dggeme764-chm.china.huawei.com ([10.6.80.72]) by dggeme764-chm.china.huawei.com ([10.6.80.72]) with mapi id 15.01.1913.007; Wed, 29 Apr 2020 15:16:53 +0800 From: "Zhanghaijian (A)" To: "gcc-patches@gcc.gnu.org" Subject: [PATCH PR94708] [8/9/10 Regression] pr94780.c fails with ICE on aarch64 Thread-Topic: [PATCH PR94708] [8/9/10 Regression] pr94780.c fails with ICE on aarch64 Thread-Index: AdYd9TOMDekGHXAESTidot2lVLfOAA== Date: Wed, 29 Apr 2020 07:16:53 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.173.220.99] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Spam-Status: No, score=-21.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_NUMSUBJECT, SPF_HELO_PASS, 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi This is a simple fix for pr94820. The PR was only fixed on i386, the same error was also reported on aarch64. This function, because it is sometimes called even outside of function bodies, uses create_tmp_var_raw rather than create_tmp_var. But in order for that to work, when first referenced, the VAR_DECLs need to appear in a TARGET_EXPR so that during gimplification the var gets the right DECL_CONTEXT and is added to local decls. Without that, e.g. tree-nested.c ICEs on those. Attached please find the v1 patch which is suitable for git am. Bootstrap and tested on aarch64 Linux platform. No new regression witnessed. From 538bafed0d4704b588769a97756e4b5a6312b7ad Mon Sep 17 00:00:00 2001 From: z00219097 Date: Wed, 29 Apr 2020 14:30:23 +0800 Subject: [PATCH] aarch64: Fix up aarch64_atomic_assign_expand_fenv [PR94820] This function, because it is sometimes called even outside of function bodies, uses create_tmp_var_raw rather than create_tmp_var. But in order for that to work, when first referenced, the VAR_DECLs need to appear in a TARGET_EXPR so that during gimplification the var gets the right DECL_CONTEXT and is added to local decls. Without that, e.g. tree-nested.c ICEs on those. 2020-04-29 Haijian Zhang PR target/94820 * config/aarch64/aarch64-builtins.c (aarch64_atomic_assign_expand_fenv): Use TARGET_EXPR instead of MODIFY_EXPR for first assignment to fenv_cr, fenv_sr and new_fenv_var. --- gcc/config/aarch64/aarch64-builtins.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c index 5744e68ea08..95213cd70c8 100644 --- a/gcc/config/aarch64/aarch64-builtins.c +++ b/gcc/config/aarch64/aarch64-builtins.c @@ -2313,10 +2313,12 @@ aarch64_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) mask_sr = build_int_cst (unsigned_type_node, ~(AARCH64_FE_ALL_EXCEPT)); - ld_fenv_cr = build2 (MODIFY_EXPR, unsigned_type_node, - fenv_cr, build_call_expr (get_fpcr, 0)); - ld_fenv_sr = build2 (MODIFY_EXPR, unsigned_type_node, - fenv_sr, build_call_expr (get_fpsr, 0)); + ld_fenv_cr = build4 (TARGET_EXPR, unsigned_type_node, + fenv_cr, build_call_expr (get_fpcr, 0), + NULL_TREE, NULL_TREE); + ld_fenv_sr = build4 (TARGET_EXPR, unsigned_type_node, + fenv_sr, build_call_expr (get_fpsr, 0), + NULL_TREE, NULL_TREE); masked_fenv_cr = build2 (BIT_AND_EXPR, unsigned_type_node, fenv_cr, mask_cr); masked_fenv_sr = build2 (BIT_AND_EXPR, unsigned_type_node, fenv_sr, mask_sr); @@ -2348,8 +2350,9 @@ aarch64_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) __atomic_feraiseexcept (new_fenv_var); */ new_fenv_var = create_tmp_var_raw (unsigned_type_node); - reload_fenv = build2 (MODIFY_EXPR, unsigned_type_node, - new_fenv_var, build_call_expr (get_fpsr, 0)); + reload_fenv = build4 (TARGET_EXPR, unsigned_type_node, + new_fenv_var, build_call_expr (get_fpsr, 0), + NULL_TREE, NULL_TREE); restore_fnenv = build_call_expr (set_fpsr, 1, fenv_sr); atomic_feraiseexcept = builtin_decl_implicit (BUILT_IN_ATOMIC_FERAISEEXCEPT); update_call = build_call_expr (atomic_feraiseexcept, 1,