From patchwork Fri Jan 12 09:43:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 187631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp63345dyc; Fri, 12 Jan 2024 01:44:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwmZsi8Kd+9hqbbCk7lSuJCMgL3bEMm58iDgEifXv91VPa3YUmOdVvJa4yZqW4WlVz2fUE X-Received: by 2002:a25:8251:0:b0:dbe:b5e9:2ac6 with SMTP id d17-20020a258251000000b00dbeb5e92ac6mr406372ybn.104.1705052676968; Fri, 12 Jan 2024 01:44:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705052676; cv=pass; d=google.com; s=arc-20160816; b=SIDxi096nMeft+v46l+ujBSv3ve3yiuZus8+qkhpEK41kaPhAkkY7CXkt29WyREUl8 7J5VU16bMF73BZ41WI67AK2vobYQFXUvT5GfBT4/PYb7o7GH9jhthoqE6XWqa7Kh5f9S MPWYbFKxAzwax4Mp6yDZ0xgNUWNaNSd0DEic0gg/qTt5OAIr7q9+PKlA4Mky9kG7p2iH fRrizY2M+r2bNWPnwB4ITeQQ/ckVhHvjId2c+mIEBQdu9l8ejOzqddFUA5A3QqPRtrj2 IT/1ltItdbo31Ya6DUc06YkArqno+oUdOuf3MkbUUWAjpF1xSU+3MXhInM1vehoOD3P2 ZRfQ== 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=uG/wZoP97Y2Pt3jSxqeiQ7gbzUphUR72Bx9J04DRmmU=; fh=ZxQlaTZlTEHWR1BocGDT+NjbbJsm2kNYJHu2THG5Yp8=; b=fM+CkmgZSKFggTqBS69myH8/VqymuA3kOkjdEn1h/EAXgQJQsxblNfP2SuwdXQWEpL +Apq5pW+xqKYSX9GBf9g2OgELX4xYhgFqnxUKrGVbEWSJ/50AYQJOexQpsgJ5shJd01y 0fS5BN0rBchNh9MbVYcs/FBB9PMsozP35QAacYQzJ1mD3J+qwcNmNqmhVW2o24NJlPJZ HGdSnnYpYtrcF7GfJyAXTd3fyo+mL0TSJiaNaG0/ZulZHvyVWrurufbFV2jPTCl2w1QA Kd1Y9hIYs/fJ6cQT9tmAzqfUoPb8sOFLIXfSFOr90yc+T+MzJnzeD6Pb4zvoeMi8QrCY N3JQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JUjqc3ce; 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 m16-20020a05622a055000b004299561a67esi2598713qtx.351.2024.01.12.01.44.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 01:44:36 -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=JUjqc3ce; 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 A87703858D37 for ; Fri, 12 Jan 2024 09:44:36 +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 B6DE538582AD for ; Fri, 12 Jan 2024 09:43:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B6DE538582AD 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 B6DE538582AD 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=1705052618; cv=none; b=GZFd+blGLMRiylQHm4ADpOMOSk234dwq0tEW56D3Zm+fTz97DQXsmzmFTANWyiAbI//CRkErPBQwrMSBktGlbter/C6CmR+6EjIiIAYoAwFu2jbg+MN+6IH9rmS1zUMc+USRQW0oNnwur/9x7EW8W3KGU3mwYiY+8WydVqtuJPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705052618; c=relaxed/simple; bh=Het2T+KTwlstk5LeouB+GhFmI5PvWFXyHNr7/UV5Hko=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=bM5KjheBMZ+CBW2ci6nbMHyrgPoF6dGMsLYoyOpnWTA7Kl9m3Ro5qJAsGqK8ckH8nIYYo66iR+1ASezQ6znMSRSqlKyog96dD/PRizcxtQ62UeqwdTO+C14kllD47nYKxiezlOeO5ZsUKGA/Mt24Ot9Ktr32XBp+FlpvcGuckz4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705052615; 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=uG/wZoP97Y2Pt3jSxqeiQ7gbzUphUR72Bx9J04DRmmU=; b=JUjqc3cegTjYylvXpuJYeQzQNpwiKvOmp+3/OTTTyi4iKHMU7Tdx2wEmDGGPmk1ACX5G8v v0Ah+WFeeW/+Z6WRKR71OiPm9B+7qJq8wswIqxTUASNb8FaW9ONdygycJ+oJiDi8xOCrxR 6R1krNq54CFomRFQnEBtPy7ZTgJKb98= 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-100-vSFOl9KKPsGisu5Ilk2Q9w-1; Fri, 12 Jan 2024 04:43:31 -0500 X-MC-Unique: vSFOl9KKPsGisu5Ilk2Q9w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 703E585A58B; Fri, 12 Jan 2024 09:43:31 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 321DCC19060; Fri, 12 Jan 2024 09:43:31 +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 40C9hSH63307057 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 12 Jan 2024 10:43:28 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40C9hR8t3307056; Fri, 12 Jan 2024 10:43:27 +0100 Date: Fri, 12 Jan 2024 10:43:27 +0100 From: Jakub Jelinek To: Richard Biener , Martin Jambor Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] sra: Punt for too large _BitInt accesses [PR113330] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, 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: 1787877315439146076 X-GMAIL-MSGID: 1787877315439146076 Hi! This is the case I was talking about in https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642423.html and Zdenek kindly found a testcase for it. We can only create BITINT_TYPE with precision at most 65535, not 65536, so need to punt if we'd want to create it. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-01-12 Jakub Jelinek PR tree-optimization/113330 * tree-sra.cc (create_access): Punt for BITINT_TYPE accesses with too large size. * gcc.dg/bitint-69.c: New test. Jakub --- gcc/tree-sra.cc.jj 2024-01-10 12:45:54.293851670 +0100 +++ gcc/tree-sra.cc 2024-01-11 15:13:29.697073438 +0100 @@ -967,6 +967,12 @@ create_access (tree expr, gimple *stmt, disqualify_candidate (base, "Encountered an access beyond the base."); return NULL; } + if (TREE_CODE (TREE_TYPE (expr)) == BITINT_TYPE + && size > WIDE_INT_MAX_PRECISION - 1) + { + disqualify_candidate (base, "Encountered too large _BitInt access."); + return NULL; + } access = create_access_1 (base, offset, size); access->expr = expr; --- gcc/testsuite/gcc.dg/bitint-69.c.jj 2024-01-11 15:16:57.573140907 +0100 +++ gcc/testsuite/gcc.dg/bitint-69.c 2024-01-12 09:55:30.026374627 +0100 @@ -0,0 +1,25 @@ +/* PR tree-optimization/113330 */ +/* { dg-do compile { target bitint } } */ +/* { dg-require-stack-check "generic" } */ +/* { dg-options "-std=c23 -O --param=large-stack-frame=131072 -fstack-check=generic --param=sccvn-max-alias-queries-per-access=0" } */ + +_BitInt(8) a; + +static inline __attribute__((__always_inline__)) void +bar (int, int, int, int, int, int, int, int) +{ +#if __BITINT_MAXWIDTH__ >= 65535 + _BitInt(65535) b = 0; + _BitInt(383) c = 0; +#else + _BitInt(63) b = 0; + _BitInt(39) c = 0; +#endif + a = b; +} + +void +foo (void) +{ + bar (0, 0, 0, 0, 0, 0, 0, 0); +}