From patchwork Wed Jan 17 09:46:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 84235 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 716693858C2C for ; Wed, 17 Jan 2024 09:47:32 +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 0E8DA3858D20 for ; Wed, 17 Jan 2024 09:47:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E8DA3858D20 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 0E8DA3858D20 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=1705484826; cv=none; b=Pzff7KBQRK+Oi4Cc2PgCio00qKXbb6qNTA0DBOtMdzRHbbxidW7mp1zonczhzOz0Gs9G0A5ZkQqmHYrmiN/bVc1E4gHitNnWpSBf6pxno69u3/C08j8XxT8q83AikrCHjF1Yzzvik8fIr69OilsfICOi+w5AlbTghkxpFfnxH20= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705484826; c=relaxed/simple; bh=iF7tTBs5pIVv/JYcJFKmNk0jn6etkpR/+XJnhN+e9O8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ENzQhZxNCLCJe/fAxdGxSXzdjchCSWthKy+0W795BjczqWdr3SJ/9mFBZ7yLnDk8l13ZCr4aGKxivI9ndUoIP0huWp55yj3tAVWlfbyXUPvXUOoeEo+9/rpMqWm1r0B5Mxh8wxS5jdHkJDFbv5P2+F8FeG0OtMrelGAvmPmDDpE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705484822; 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=142FoCsgvz/3bK0wBQGCmW0BqSw2Mq40Ncrk56AiVHY=; b=c/7LBK6UET7yhBzlfmG2BJ0fOgHz1a6J1b2d15IotAZVGWgxoOZrACuno/fro6/a4ooUiK FjDpMZJHZOXdCRwJlNtMna7+CEFKGAP2UK2xFLyd1fwVqloqzkwD6g/MkA5IkCvi2rmJL/ s7ZdUeEi6yaPbjpsit4Wgd165ahpG9E= 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-287-9nf6GJZUOmqDSCGBypxUSg-1; Wed, 17 Jan 2024 04:47:00 -0500 X-MC-Unique: 9nf6GJZUOmqDSCGBypxUSg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 81EED299E749; Wed, 17 Jan 2024 09:47:00 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 467DA51E3; Wed, 17 Jan 2024 09:47:00 +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 40H9kvCm2306864 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jan 2024 10:46:58 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40H9kvcH2306861; Wed, 17 Jan 2024 10:46:57 +0100 Date: Wed, 17 Jan 2024 10:46:56 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.6 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! Unlike NOP_EXPR/CONVERT_EXPR which are GIMPLE_UNARY_RHS, VIEW_CONVERT_EXPR is GIMPLE_SINGLE_RHS and so gimple_assign_rhs1 contains the operand wrapped in VIEW_CONVERT_EXPR tree. So, to handle it like other casts we need to look through it. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-01-17 Jakub Jelinek PR tree-optimization/113408 * gimple-lower-bitint.cc (bitint_large_huge::handle_stmt): For VIEW_CONVERT_EXPR, pass TREE_OPERAND (rhs1, 0) rather than rhs1 to handle_cast. * gcc.dg/bitint-71.c: New test. Jakub --- gcc/gimple-lower-bitint.cc.jj 2024-01-15 17:34:00.000000000 +0100 +++ gcc/gimple-lower-bitint.cc 2024-01-16 12:32:56.617721208 +0100 @@ -1975,9 +1975,12 @@ bitint_large_huge::handle_stmt (gimple * case INTEGER_CST: return handle_operand (gimple_assign_rhs1 (stmt), idx); CASE_CONVERT: - case VIEW_CONVERT_EXPR: return handle_cast (TREE_TYPE (gimple_assign_lhs (stmt)), gimple_assign_rhs1 (stmt), idx); + case VIEW_CONVERT_EXPR: + return handle_cast (TREE_TYPE (gimple_assign_lhs (stmt)), + TREE_OPERAND (gimple_assign_rhs1 (stmt), 0), + idx); default: break; } --- gcc/testsuite/gcc.dg/bitint-71.c.jj 2024-01-16 12:38:16.679239526 +0100 +++ gcc/testsuite/gcc.dg/bitint-71.c 2024-01-16 12:37:24.724967020 +0100 @@ -0,0 +1,18 @@ +/* PR tree-optimization/113408 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c23 -O2" } */ + +#if __BITINT_MAXWIDTH__ >= 713 +struct A { _BitInt(713) b; } g; +#else +struct A { _BitInt(49) b; } g; +#endif +int f; + +void +foo (void) +{ + struct A j = g; + if (j.b) + f = 0; +}