From patchwork Wed Nov 3 10:12:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 46986 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EEDD3385840A for ; Wed, 3 Nov 2021 13:47:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEDD3385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635947231; bh=CVG1b6655PzrzeGomw3BomcQ7hvqroGG29wSn4O86m4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZQmpHHs0sQBE87WywpBoE2Q252RaJO6qDw3Jav709stkEt7xq17z56sK15M6H0OWc eB5HMPyEvRU/mQJNl2JaL6mZTSqWbJjq8URf2cn8u+YzalVKPr0z5z5orFQS2oMzNn 6/WAoY0pn5rrowko7nM7uNlyE1hPwqcgm2+wHOeU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 4C246385840D for ; Wed, 3 Nov 2021 13:34:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C246385840D Received: from smtp-out1.suse.de ([195.135.220.28]:45752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1miDG7-0004qX-64 for gcc-patches@gcc.gnu.org; Wed, 03 Nov 2021 06:12:44 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DCD5D218A8 for ; Wed, 3 Nov 2021 10:12:40 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CA00513CE7 for ; Wed, 3 Nov 2021 10:12:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UKo8MJhggmHyCgAAMHmgww (envelope-from ) for ; Wed, 03 Nov 2021 10:12:40 +0000 Date: Wed, 3 Nov 2021 11:12:40 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] middle-end/103033 - drop native_interpret_expr with .DEFERRED_INIT expansion Message-ID: <251n273q-14sr-7n9o-884p-5915nq36o5qs@fhfr.qr> MIME-Version: 1.0 Received-SPF: pass client-ip=195.135.220.28; envelope-from=rguenther@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_SOFTFAIL, 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This drops the use of native_interpret_expr which can fail even though can_native_interpret_expr_p returns true in favor of simply folding the VIEW_CONVERT_EXPR punning. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-11-03 Richard Biener PR middle-end/103033 * internal-fn.c (expand_DEFERRED_INIT): Elide the native_interpret_expr path in favor of folding the VIEW_CONVERT_EXPR generated when punning the RHS. --- gcc/internal-fn.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index fd6cb0995d9..0cba95411a6 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -3070,9 +3070,11 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt) } else { - /* If this variable is in a register use expand_assignment. */ + /* If this variable is in a register use expand_assignment. + For boolean scalars force zero-init. */ tree init; - if (tree_fits_uhwi_p (var_size) + if (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE + && tree_fits_uhwi_p (var_size) && (init_type == AUTO_INIT_PATTERN || !is_gimple_reg_type (var_type)) && int_mode_for_size (tree_to_uhwi (var_size) * BITS_PER_UNIT, @@ -3082,21 +3084,16 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt) unsigned char *buf = (unsigned char *) xmalloc (total_bytes); memset (buf, (init_type == AUTO_INIT_PATTERN ? INIT_PATTERN_VALUE : 0), total_bytes); - if (can_native_interpret_type_p (var_type)) - init = native_interpret_expr (var_type, buf, total_bytes); + tree itype = build_nonstandard_integer_type + (total_bytes * BITS_PER_UNIT, 1); + wide_int w = wi::from_buffer (buf, total_bytes); + init = wide_int_to_tree (itype, w); + /* Pun the LHS to make sure its type has constant size + unless it is an SSA name where that's already known. */ + if (TREE_CODE (lhs) != SSA_NAME) + lhs = build1 (VIEW_CONVERT_EXPR, itype, lhs); else - { - tree itype = build_nonstandard_integer_type - (total_bytes * BITS_PER_UNIT, 1); - wide_int w = wi::from_buffer (buf, total_bytes); - init = wide_int_to_tree (itype, w); - /* Pun the LHS to make sure its type has constant size - unless it is an SSA name where that's already known. */ - if (TREE_CODE (lhs) != SSA_NAME) - lhs = build1 (VIEW_CONVERT_EXPR, itype, lhs); - else - init = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), init); - } + init = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), init); } else /* Use zero-init also for variable-length sizes. */