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: 84480 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 B1D573858409 for ; Sat, 20 Jan 2024 09:38:59 +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+patchwork=sourceware.org@gcc.gnu.org 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; +}