From patchwork Sat Jan 20 09:38:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 189724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp1526170dyb; Sat, 20 Jan 2024 01:39:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFLew3lu30V8c8Bb8fDfz+wm5DdPrIOLGEP74VKEcy3C+TyyL9WyKqchRdaPWewVAyQimV X-Received: by 2002:ac8:5dce:0:b0:42a:325b:e9a with SMTP id e14-20020ac85dce000000b0042a325b0e9amr405413qtx.77.1705743559403; Sat, 20 Jan 2024 01:39:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705743559; cv=pass; d=google.com; s=arc-20160816; b=0l1jcnlEQGbV2TTgmAxsu9zVOd1P0mpTmfMzBiYaFKOylmlTPa+WjRM1qKzlM6jfqP OYnyXqZZXBMPCX+U4z7SIIgEU8115DFsBOiSWrcBLjXLXX0nmE+UAGtHKDXfdUnDvAv3 OtfTwGjpqKZnfMR4OMKu3SEuMXIHZEkaR+hqy17E1pSOzYy1MOL/iVj4KTDCSO9nN7SM qYTrk2ZzoZxKAHu+uS8zV55NlfWV456y7xKQHoCCz3N0urvjhRN5kMds1K3l98uwuCSV IHuVB0Gi/Mknnw/HjesQvzszJE0ISFGcmnqJ/UeDd0HILMFMrElGR/X5LoQaDNPA1lwE aFFw== 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=G0j2mBwrRbNeOcSnlUE3VAW9WLGDvSIoY8MRenTiNPU=; fh=FCjeRajqaQYHMkQtfIia8KT5yBac53mYOLLyJhYG/AY=; b=P6WSPMMRdRXOwCxTfGD6cBlER2yRmAm9PnNevAEIVpow6SilhsVjJ5924lmHp4WeJc v0BXsGTKJZwXeiud/N/lU/8fxdzW+v7s0+zNOlbVUPi0XI21cmG9q0SOrBQouIv6RT5d dTyLEgTBdruxzxb8TvOF1P0c2ONSJyMGW+KIGCDZ4weQQwLmy4D+MpqAVSViTovnyXOF NMRYEZpnIqx134Dy3Vr72JCsa/XOGS7vdHFIFSe9GT0fz+UWUSMf9PN984tM5GcqAjX3 U+gpVAaIzPJrV0cBqoQZwMqclA16TJ4Za5yXKgr9WbRW2+PkMhy46+CFIBkHEWziH8JL 8Prg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Nm8Ba+GL; 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 pj21-20020a05620a1d9500b007835b70ff2dsi1119107qkn.371.2024.01.20.01.39.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 01:39:19 -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=Nm8Ba+GL; 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 1B5CE3858C3A for ; Sat, 20 Jan 2024 09:39:19 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id BCFD43858D39 for ; Sat, 20 Jan 2024 09:38:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BCFD43858D39 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 BCFD43858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705743508; cv=none; b=SjHcrWPsIet8qxTM2/QBEGnd/VduDWm+KxRwzwEDIaklAsQpeZ6Z45+4dWcFxgpcKM3/FdEXNKxCC1W3etuP0NMgciKoeveXIpvrjDRV+nar6TzCTYb8184QEt92O6jbI2AikssJbOuOG/Xgf5v8J5f7ycGYK1zkb1LjqKmtjto= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705743508; c=relaxed/simple; bh=dyLQU5thX8m20tGIfMdKlytljAn5xcJj9NXEe896AqQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=XcyGjkhDYN8OpmuBkPrAzw0BJseh5+mc7UAZYcwD1HPOlPsyT4rGsxGRsF2/NAwqPJR4cv9WtbY8Y9TxF0ewpPWxT9MI4j57Zt5Ohm4SSO+oorhnb7ciX6SIvbYmsxQjSRhNE+Xv9TecyK3TtpTI2d5Rfms/uHiMOY8tlMLrSoE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705743506; 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=G0j2mBwrRbNeOcSnlUE3VAW9WLGDvSIoY8MRenTiNPU=; b=Nm8Ba+GLWp9mSW5iWWRzd00fqbwGGd/NoD9dSZonn/jBWeao0XdrRMnd4Lyni6zJBrZaTM i7czRphvjuD5KK1HzvSV2R9mf/MHW4niB0Ny9GrBkEQ84EA0dCOM+IyrXDUNrVyQaB/9JW 5LU9OFBo0J0p/ia4zja3B/HFgGHtneQ= 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-645-ETr-FpXVMfuyz2qvmDxtvw-1; Sat, 20 Jan 2024 04:38:24 -0500 X-MC-Unique: ETr-FpXVMfuyz2qvmDxtvw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 3D6E329AC032; Sat, 20 Jan 2024 09:38:24 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01D2140C6EBA; Sat, 20 Jan 2024 09:38:23 +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 40K9cLOH4066136 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 20 Jan 2024 10:38:21 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40K9cKqW4066135; Sat, 20 Jan 2024 10:38:20 +0100 Date: Sat, 20 Jan 2024 10:38:20 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] lower-bitint: Handle INTEGER_CST rhs1 in handle_cast [PR113462] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.3 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: 1788601758415796196 X-GMAIL-MSGID: 1788601758415796196 Hi! The following patch ICEs because fre3 leaves around unfolded _1 = VIEW_CONVERT_EXPR<_BitInt(129)>(0); statement and in handle_cast I was expecting just SSA_NAMEs for the large/huge _BitInt to large/huge _BitInt casts; INTEGER_CST is something we can handle in that case exactly the same, as the handle_operand recursion handles those. Of course, maybe we should also try to fold_stmt such cases somewhere in bitint lowering preparation. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-01-20 Jakub Jelinek PR tree-optimization/113462 * gimple-lower-bitint.cc (bitint_large_huge::handle_cast): Handle rhs1 INTEGER_CST like SSA_NAME. * gcc.dg/bitint-76.c: New test. Jakub --- gcc/gimple-lower-bitint.cc.jj 2024-01-19 10:01:37.696673929 +0100 +++ gcc/gimple-lower-bitint.cc 2024-01-19 18:36:34.175254308 +0100 @@ -1250,7 +1250,7 @@ bitint_large_huge::handle_cast (tree lhs { tree rhs_type = TREE_TYPE (rhs1); gimple *g; - if (TREE_CODE (rhs1) == SSA_NAME + if ((TREE_CODE (rhs1) == SSA_NAME || TREE_CODE (rhs1) == INTEGER_CST) && TREE_CODE (lhs_type) == BITINT_TYPE && TREE_CODE (rhs_type) == BITINT_TYPE && bitint_precision_kind (lhs_type) >= bitint_prec_large --- gcc/testsuite/gcc.dg/bitint-76.c.jj 2024-01-19 18:39:23.883980766 +0100 +++ gcc/testsuite/gcc.dg/bitint-76.c 2024-01-19 18:38:48.758451335 +0100 @@ -0,0 +1,16 @@ +/* PR tree-optimization/113462 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c23 -O2" } */ + +#if __BITINT_MAXWIDTH__ >= 129 +typedef _BitInt(129) B; +#else +typedef _BitInt(63) B; +#endif + +B +foo (void) +{ + struct { B b; } s = {}; + return s.b; +}