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: 1885933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JUjqc3ce; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TBGnv6wQPz1yPm for ; Fri, 12 Jan 2024 20:44:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E86393858D37 for ; Fri, 12 Jan 2024 09:44:01 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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); +}