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: 208687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp929765dyb; Fri, 1 Mar 2024 00:12:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXpmUW4mmvN/LsgBq4Z0GYqR5+1vYb4+/wndRaRTQUeGxLeNztBzOT2y95uiaqN1o+W8I4V36ygBlgc8Mmx+YJo7mf4IQ== X-Google-Smtp-Source: AGHT+IFFD2oDu0MOA6KbRt74qcmPImuxJ+P7/BVtxkCuM5YZH+3tlHesT4kJRysYk2N/WnYgTEFc X-Received: by 2002:a25:ae60:0:b0:dc6:b8f5:50ae with SMTP id g32-20020a25ae60000000b00dc6b8f550aemr867186ybe.32.1709280728950; Fri, 01 Mar 2024 00:12:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709280728; cv=pass; d=google.com; s=arc-20160816; b=hmepUuBusZfIDhk9sNJj15BgJ6n2bawjHj6+eGdpApIjWBNPuSFCm7zy5vjGM1l841 w2DSt4IG7zu/eGzXMMr8ZQ3Cv4yPD3GGBSWfdJ6YsPtQrACsfeWZr2VRUISlB7TkzY1Q vdeHVHW4UE3dSXKKDYQOgLq3GV2XMTq3hkEOMz3AvlKk2UCHaFCnc/eRKfJnyGuwNZdK W3PmE6tDp3JcoVIBKmp2iFaulOWeTAdmpZ+yv6A4rTP6gJJwskFFc2TFYQ/iDiAsY2pe l3SBBEJeLddKsxdxndOqjAwJ3AtVV5D1WX5DSHIDnlSEtkZ1eYEZOjHWjb8pEhNOTaSt Wy/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=zKbMlKVWuJkesPJnviubGVinpZUbggI8k0tVMSzLbVQ=; fh=FCjeRajqaQYHMkQtfIia8KT5yBac53mYOLLyJhYG/AY=; b=beSgwR7enjOdfKv0KtzQLiv8mqQod7p6QHjWQUnbsHUvJHRJWks7KTwijJeT1LetFo mcvutjaJ+T/w0Dkpz1NCRC/IB4NiYSDcIaBthL+j8DiNXZTdSJyS4VXWhO5sjarS5QLu 6VSkVuPe5TsOCnksrNmC1qXj5OKjyiulNHXCYSdM1kIvdeUZxoSeG0tcrYprZiLxSaqv 1VVUW9zJS3/r5kn9RaTPWfcKIPWJd45eqDOoiaJvEcqYT9/Tq4U92ptnPG/MfN8c3WnM Z+z08hY9iAKWhBxweU5oOczptGfdJqNfhK8XCU25FAWW7GD3uNLMmLqGpqatVbviGJzV rekg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ldx6emEq; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e16-20020ac85990000000b0042e4e7909b0si3334540qte.95.2024.03.01.00.12.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 00:12:08 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ldx6emEq; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FCE13858C35 for ; Fri, 1 Mar 2024 08:12:08 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792310749463493847 X-GMAIL-MSGID: 1792310749463493847 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)); +}