From patchwork Fri Mar 1 08:11:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1906577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ldx6emEq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TmLQb2dZWz23fC for ; Fri, 1 Mar 2024 19:11:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A1F73858414 for ; Fri, 1 Mar 2024 08:11:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id F16CF3858C53 for ; Fri, 1 Mar 2024 08:11:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F16CF3858C53 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F16CF3858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709280671; cv=none; b=uriks2IgynOSWvEMyuKpRO9E6kgmO2Vb/aoD0bVZGwy9lDd/fXnwD3GOf8kuBKxnqBPzCoa17gMlmU7fg+I9ICRBfi3zNd8ZE/tPS/66cwfp7k2PJloth6cqhT4v2n1GM97cr+fGXJDh4Kapws4cOF/vEgQv69sNYrr7TVS8KBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709280671; c=relaxed/simple; bh=ausVbyxlJKwuDhl8iR/niLcAnH7hC68inIakKQtoLz0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=HA9ZzpPzSzMTZ6tZ+znGLobG7YqJpOIwCYPbQ4beQ8uZE3TzlBsoVbpO8yzX3I+YAaqWlky5uiHC2002SxLQA1roXcI1N06HzQgdQBS048TIMe14Hdb0XIz+46DieBpSIm5elI87RCg9J/cUne12y+Y7Tw2cm2Laz/FKc6qtM80= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709280669; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=zKbMlKVWuJkesPJnviubGVinpZUbggI8k0tVMSzLbVQ=; b=Ldx6emEqQRhPnFr0kPa2shjwS3DECMGiIKckYLTaDLIEcE9CuoJybO74g5vMI4bTATyxPl zNm4kuQIqEva0QJPygvvtB30nc9+hra7aE+Xo4Io8W+NrTh3aRgMs10nqHA5djjhsE83xh rRWvv0Ol6h6nnzWhC9tZjVl0orl0n68= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-318-myQ619k6OSqnfG-MGgtglQ-1; Fri, 01 Mar 2024 03:11:08 -0500 X-MC-Unique: myQ619k6OSqnfG-MGgtglQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D4E411C29EB9; Fri, 1 Mar 2024 08:11:07 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.226.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A236134; Fri, 1 Mar 2024 08:11:07 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 4218B585506067 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 1 Mar 2024 09:11:06 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4218B5wd506066; Fri, 1 Mar 2024 09:11:05 +0100 Date: Fri, 1 Mar 2024 09:11:05 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] bitint: Handle VCE from large/huge _BitInt SSA_NAME from load [PR114156] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! When adding checks in which case not to merge a VIEW_CONVERT_EXPR from large/huge _BitInt to vector/complex etc., I missed the case of loads. Those are handled differently later. Anyway, I think the load case is something we can handle just fine, so the following patch does that instead of preventing the merging gimple_lower_bitint; we'd then copy from memory to memory and and do the vce only on the second one, it is just better to vce the first one. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-03-01 Jakub Jelinek PR middle-end/114156 * gimple-lower-bitint.cc (bitint_large_huge::lower_stmt): Allow rhs1 of a VCE to have no underlying variable if it is a load and handle that case. * gcc.dg/bitint-96.c: New test. Jakub --- gcc/gimple-lower-bitint.cc.jj 2024-02-24 12:44:27.993108306 +0100 +++ gcc/gimple-lower-bitint.cc 2024-02-29 19:28:59.442020619 +0100 @@ -5329,6 +5329,22 @@ bitint_large_huge::lower_stmt (gimple *s gimple_assign_set_rhs1 (stmt, rhs1); gimple_assign_set_rhs_code (stmt, SSA_NAME); } + else if (m_names == NULL + || !bitmap_bit_p (m_names, SSA_NAME_VERSION (rhs1))) + { + gimple *g = SSA_NAME_DEF_STMT (rhs1); + gcc_assert (gimple_assign_load_p (g)); + tree mem = gimple_assign_rhs1 (g); + tree ltype = TREE_TYPE (lhs); + addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (mem)); + if (as != TYPE_ADDR_SPACE (ltype)) + ltype + = build_qualified_type (ltype, + TYPE_QUALS (ltype) + | ENCODE_QUAL_ADDR_SPACE (as)); + rhs1 = build1 (VIEW_CONVERT_EXPR, ltype, mem); + gimple_assign_set_rhs1 (stmt, rhs1); + } else { int part = var_to_partition (m_map, rhs1); --- gcc/testsuite/gcc.dg/bitint-96.c.jj 2024-02-29 19:37:27.441032088 +0100 +++ gcc/testsuite/gcc.dg/bitint-96.c 2024-02-29 19:36:34.815753879 +0100 @@ -0,0 +1,17 @@ +/* PR middle-end/114156 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-msse2" { target i?86-*-* x86_64-*-* } } */ + +#if __BITINT_MAXWIDTH__ >= 128 +_BitInt(128) a, b; +#else +int a, b; +#endif + +void +foo (void) +{ + int u = b; + __builtin_memmove (&a, &b, sizeof (a)); +}