From patchwork Thu Nov 23 10:04:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 168840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp336668vqx; Thu, 23 Nov 2023 02:04:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnHrYeICyNCEHTYNq49Pdnz/eiPdyC5BCimhoUpKEHt62evwZKWmybvwG5eId3C0DAe8z+ X-Received: by 2002:a05:6214:40a:b0:679:f2c2:2f1f with SMTP id z10-20020a056214040a00b00679f2c22f1fmr6493500qvx.46.1700733893710; Thu, 23 Nov 2023 02:04:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700733893; cv=pass; d=google.com; s=arc-20160816; b=ANT3MKzzVzgzDETTx+MX1ipWR8CfYQA116TiLp4JsrD/OXlXvdVvWJnFvCdB0WMXQy 1IAJVymyh1OCBbJILiGKu8QyE2ufsWDjTFuzrlqc4GVDot46E/Tz+N6S1D6YkjM3p9rQ M/kLip/U4V2bxvCPCDg1eixzRueMzn/8Ut4W6XnA1hvokP++6tjYHBewziF/PhxVU1/j +kkuFccrbge5LGvNZulvUxHauTiUdXiEnzH+54zXp1PWwJZ6NSY4aVjrnu6gO+SMf984 fOCHAVLP4rxVGZ6pACFQNXlIsCK47aVbRyyWFkORi6H8nJLfZxG4Tn2c9VcH4q660WuY BidQ== 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=KwM0SNR1GFgLSAQC/Nzvfk3BQxucG4VDTBW0FjAu+tY=; fh=FCjeRajqaQYHMkQtfIia8KT5yBac53mYOLLyJhYG/AY=; b=JsBP71LkXsZ5RJpgVbOnTtmH3buls0iKD3ywAdwu0DU7qX7C9DFNs3EyznbqRx/2Hg O4QR4oiByf3lOuilXxfM0xmJ+YHJDralzcbPkXIhjIbAGw902/K3g5K2BZqoK0ShMXfm PAf9iY8Ow1AlJu2ELJ1rjPFI7ZwrVcDk41fYGgVGak0dBbRy5IukcpI0oMUhWs9PZtrh gcUICedHjf4n+JH65PzikUixtUCzfh2wl+kR0XPkqXPGA4g4R9l2agWShZFTMAz1yMTH QVm2NdPXnZyRL2RrP6HAYEq1tyeIvKBnZjLoUsGPyrJ7D8+6y9gAE4A/i5sNmK6mQFTt Zl/g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iqKOmS4L; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j15-20020a0cf9cf000000b0066cfc2c8139si837057qvo.377.2023.11.23.02.04.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 02:04:53 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iqKOmS4L; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 287BC385841C for ; Thu, 23 Nov 2023 10:04:53 +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 BE8293858C52 for ; Thu, 23 Nov 2023 10:04:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE8293858C52 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 BE8293858C52 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=1700733870; cv=none; b=CqkUCdTwkNxaSeh5zZUa2NauIJkwCSVbQzfcOZ1IB/em5zUvi6xhCHuHlxk36P6s/8J7fti9+3VkuEBJ784VUNolE+ih13ZINwKqgpmsncoYFJHaAQyHOczuDDeEKnbHfS/KbmqWLR5BmKiUnyhQmeiHfDNTwIiAsT+KC45L61s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700733870; c=relaxed/simple; bh=LAtb3kdQtY/RmlLxbkgVG7LqhOQayXEEOhqvlxieXrI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=LrlgWp7yIYZeBfbZMkZ7OM2Jb8LWCvoeJ0io+XYSP1kf327yg1kfVHfrNtymnUZixLkLaclZmNJqXGpHcVZ8sM419rrU8PABsBlH105TeE92Qa0FoRPS660vNagka7QltdNKPZLJNeU48wHDaoPiG5mFh/Ra+wdWBgpKAI3c4wo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700733868; 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=KwM0SNR1GFgLSAQC/Nzvfk3BQxucG4VDTBW0FjAu+tY=; b=iqKOmS4LOulW3Dppmg862ZF8fo3bN1/AW4V+YU5LmjKb5Bqe7ebVM0UjbLRkcnhYD/0R/u k9N96cQND8Q1XXu0XoTDPacEadzs/hHp/UwUjmFeld8pJzr04iQCyfNuBgSg/MLTQpb7NR +b0z5dG5tvQJT4TjACmBoeUIMyboDFQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-e3GtRJY5M5WX2oWfhaVH8g-1; Thu, 23 Nov 2023 05:04:26 -0500 X-MC-Unique: e3GtRJY5M5WX2oWfhaVH8g-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 AB5F9185A781; Thu, 23 Nov 2023 10:04:26 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FA8440C6EB9; Thu, 23 Nov 2023 10:04:26 +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 3ANA4NLJ888856 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 11:04:23 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3ANA4MxA888855; Thu, 23 Nov 2023 11:04:22 +0100 Date: Thu, 23 Nov 2023 11:04:22 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] expr: Fix &bitint_var handling in initializers [PR112336] 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=-3.4 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_H3, 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: 1783348743631403519 X-GMAIL-MSGID: 1783348743631403519 Hi! As the following testcase shows, we ICE when trying to emit ADDR_EXPR of a bitint variable which doesn't have mode width. The problem is in the EXTEND_BITINT stuff which makes sure we treat the padding bits on memory reads from user bitint vars as undefined. When expanding ADDR_EXPR on such vars inside outside of initializers, expand_expr_addr* uses EXPAND_CONST_ADDRESS modifier and EXTEND_BITINT does nothing, but in initializers it keeps using EXPAND_INITIALIZER modifier. So, we need to treat EXPAND_INITIALIZER the same as EXPAND_CONST_ADDRESS for this regard. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-11-23 Jakub Jelinek PR middle-end/112336 * expr.cc (EXTEND_BITINT): Don't call reduce_to_bit_field_precision if modifier is EXPAND_INITIALIZER. * gcc.dg/bitint-41.c: New test. Jakub --- gcc/expr.cc.jj 2023-11-14 18:26:05.401613476 +0100 +++ gcc/expr.cc 2023-11-22 19:03:59.121599029 +0100 @@ -10698,6 +10698,7 @@ expand_expr_real_1 (tree exp, rtx target && mode != BLKmode \ && modifier != EXPAND_MEMORY \ && modifier != EXPAND_WRITE \ + && modifier != EXPAND_INITIALIZER \ && modifier != EXPAND_CONST_ADDRESS) \ ? reduce_to_bit_field_precision ((expr), NULL_RTX, type) : (expr)) --- gcc/testsuite/gcc.dg/bitint-41.c.jj 2023-11-22 19:09:48.986726861 +0100 +++ gcc/testsuite/gcc.dg/bitint-41.c 2023-11-22 19:09:29.804993983 +0100 @@ -0,0 +1,36 @@ +/* PR middle-end/112336 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x" } */ + +unsigned _BitInt(1) v1; +unsigned _BitInt(1) *p1 = &v1; +signed _BitInt(2) v2; +signed _BitInt(2) *p2 = &v2; +unsigned _BitInt(11) v11; +unsigned _BitInt(11) *p11 = &v11; +signed _BitInt(12) v12; +signed _BitInt(12) *p12 = &v12; +unsigned _BitInt(21) v21; +unsigned _BitInt(21) *p21 = &v21; +signed _BitInt(22) v22; +signed _BitInt(22) *p22 = &v22; +unsigned _BitInt(31) v31; +unsigned _BitInt(31) *p31 = &v31; +signed _BitInt(32) v32; +signed _BitInt(32) *p32 = &v32; +unsigned _BitInt(41) v41; +unsigned _BitInt(41) *p41 = &v41; +signed _BitInt(42) v42; +signed _BitInt(42) *p42 = &v42; +#if __BITINT_MAXWIDTH__ >= 128 +unsigned _BitInt(127) v127; +unsigned _BitInt(127) *p127 = &v127; +signed _BitInt(128) v128; +signed _BitInt(128) *p128 = &v128; +#endif +#if __BITINT_MAXWIDTH__ >= 258 +unsigned _BitInt(257) v257; +unsigned _BitInt(257) *p257 = &v257; +signed _BitInt(258) v258; +signed _BitInt(258) *p258 = &v258; +#endif