From patchwork Fri Jun 23 12:14:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1798861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.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=uxbTZ0+E; 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qnbm350Rpz20Wk for ; Fri, 23 Jun 2023 22:15:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF9083858025 for ; Fri, 23 Jun 2023 12:15:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF9083858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687522513; bh=XArGk3fs+4EbasEBi2zUOLW7OpFNESJ0X0PkW5ie4QU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uxbTZ0+Eq9lm05/OIUNXKgkJgsUsMJFT7SUjNqfEC7cEb8wvhtuqXnK6uQJfSBbQm jsLxGZnovr+Re30wE+2YHQu7r1RI5+6P6VxqNy1ltu8rZ4f5eZ8W3cMPBsjJP+D5Qf 6G652MmZo3Vw9+3FouaCe/fTiMNBAQp9b5XUqy/I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id D7B323858439 for ; Fri, 23 Jun 2023 12:14:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7B323858439 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 E359721B0D for ; Fri, 23 Jun 2023 12:14:52 +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 CF5F2134FB for ; Fri, 23 Jun 2023 12:14:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9hVwMbyMlWTNLgAAMHmgww (envelope-from ) for ; Fri, 23 Jun 2023 12:14:52 +0000 Date: Fri, 23 Jun 2023 14:14:52 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix initializer_constant_valid_p_1 TYPE_PRECISION use MIME-Version: 1.0 Message-Id: <20230623121452.CF5F2134FB@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" initializer_constant_valid_p_1 is letting through all conversions of float vector types that have the same number of elements but that's of course not valid. The following restricts the code to scalar floating point types as was probably intended (only scalar integer types are handled as well). Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * varasm.cc (initializer_constant_valid_p_1): Only allow conversions between scalar floating point types. --- gcc/varasm.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/varasm.cc b/gcc/varasm.cc index dd84754a283..f2a19aa6dbd 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -4885,7 +4885,8 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache) /* Allow length-preserving conversions between integer types and floating-point types. */ if (((INTEGRAL_TYPE_P (dest_type) && INTEGRAL_TYPE_P (src_type)) - || (FLOAT_TYPE_P (dest_type) && FLOAT_TYPE_P (src_type))) + || (SCALAR_FLOAT_TYPE_P (dest_type) + && SCALAR_FLOAT_TYPE_P (src_type))) && (TYPE_PRECISION (dest_type) == TYPE_PRECISION (src_type))) return initializer_constant_valid_p_1 (src, endtype, cache);