From patchwork Fri Jan 19 08:45:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 189443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp875580dyb; Fri, 19 Jan 2024 00:49:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHceYk70vI3vEHyRHKRJKCnaglpFtq+/+mpr2yOeaUyfvEbDAZeba+2M7X72WBijIlGIbh X-Received: by 2002:a05:6214:f06:b0:681:2391:ece0 with SMTP id gw6-20020a0562140f0600b006812391ece0mr2521272qvb.59.1705654159287; Fri, 19 Jan 2024 00:49:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705654159; cv=pass; d=google.com; s=arc-20160816; b=A+3EDbD8NgXDOz3K2CbUDdKAVvyRzkTRfLfwwWL2Wo/dHCbOz9gu/iYlueJZqCRtOZ JKFUcHRqzYKT/sKfvPWvoNkhJpu5HyCdp3YtNCYskFU5urXKibzmU8QAWkYMTBnmyL2h 4o94CXIMWWs7jA7U9e6Pw/S4mvjg6k7XThLQ2N85LWjq+0JwPPH5pXuuEaNRN+Si0dQ/ MTPZ5Qic7IlnOQaREKk8Ox2Db/eyVk6LPY4081nKrPLbAzax8AMFKclJad8DS2fV1xHC zB9RKrN56rmFPL/IwiWrpoWirylrKByPYqF7Rv+E97kJ80YYR2YSobyeHJ45BfFJgGsM taFg== 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=t5s1FpMjasa/GgkkIeqe13fAW89PxQsF2UPbJ7LjPh8=; fh=FCjeRajqaQYHMkQtfIia8KT5yBac53mYOLLyJhYG/AY=; b=HaDCAq3NFfUZ6RPwtORHG94J7EmQRUgG/Or0aGkZNVuci5JAL4YuNINSwjOYUEXq4O 3vJTarI6tpIkJ0qH29sUgSg+NtNquj7rOq2+rzRtsxjs/SXwh8qfG1vPXuivOWy3z8Q8 TT9NgCj+9y7ZrUaK95rnWh7ggcnl/FYk0cldjqz0v+oN5R2gKSq53yQXDtxzp5BdLs+m apZXOlPXzUDSzKhzi7WijAEU5aQYnQ3LHLwINe+Hz4u5YQjRCWYJUK9t3VKqlysa63lT bJITXrJyKIj1ytAiBAJrBN5iQ/2vokEWUwgUo1xXqSUYtaGlT6bouDmLHSXx2FUXjrSx H75g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RoHoJJY7; 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 n11-20020a0c8c0b000000b0067f969c9f65si16087394qvb.33.2024.01.19.00.49.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 00:49:19 -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=RoHoJJY7; 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 A76FC3858C2D for ; Fri, 19 Jan 2024 08:49:18 +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 21B9E3858C60 for ; Fri, 19 Jan 2024 08:46:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21B9E3858C60 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 21B9E3858C60 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=1705653974; cv=none; b=ZHj0V8PPyUFnSjYtDfN4Uxag9AU5axZ8a59XsH9DlWRCfDET7PLHdXeABmOm1YTYaS9BcFhuaXGKj20HHW+sqjxP9kBVYxcSI/Mm0iphON91MfZg8to3fWVdIYcxSON/sMo8nFIcrNzxBo3ZhJvzuvZIs7V7i3FrplOUPmbObww= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705653974; c=relaxed/simple; bh=KuQ+FE8qDyRM+p6kQyDY4y12znlmJAL9qz1tidJNRLc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=FJb3MWuRCQ7xgGHVpmX5Xk8pj+T3rR53nTKZHf/KaRZB2T4fg3mgGmVWsQayiJStuFhXJx9ZxDbu9dqcxcjcUAtOXIo3ffIi5yUcpMyqw11wucf+n9F0E3smtSyxrX8OeF7gsF7PoCjHco2VXAAT3+jZBNULXKOSr+wF8NvDP8w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705653964; 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=t5s1FpMjasa/GgkkIeqe13fAW89PxQsF2UPbJ7LjPh8=; b=RoHoJJY7R4qLihf1AnvBKoR3ZIiiswygcU2+LBjeg1VMW0rtAkIX78kPQvKoS1ebouAd00 io1eEaJmjuJKI60k3BnkrvTDEaRt4uuFog4s3IzuQHPgiRePmm4Pkjpy/E6/cWBRKv+lKT B7C1Of16+/8bS96N+j9sg5x5b/iRn90= 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-100-ZEZGQbLqOW2-UBWjdlCpQA-1; Fri, 19 Jan 2024 03:46:03 -0500 X-MC-Unique: ZEZGQbLqOW2-UBWjdlCpQA-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 F11533806713; Fri, 19 Jan 2024 08:46:02 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B56CB40D1B60; Fri, 19 Jan 2024 08:46:02 +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 40J8k04H1212690 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 19 Jan 2024 09:46:00 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40J8jxUV1212689; Fri, 19 Jan 2024 09:45:59 +0100 Date: Fri, 19 Jan 2024 09:45:59 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] sccvn: Don't use SCALAR_INT_TYPE_MODE on BLKmode BITINT_TYPEs [PR113459] 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.9 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: 1788508015488101327 X-GMAIL-MSGID: 1788508015488101327 Hi! sccvn uses GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)) for INTEGER_TYPEs, most likely because that is what native_{interpret,encode}_int used. This obviously doesn't work for larger BITINT_TYPEs which have BLKmode and the above ICEs on those. native_{interpret,encode}_int checks whether the BITINT_TYPE is medium/large/huge (i.e. an array of 2+ ABI limbs) and uses TYPE_SIZE_UNIT for that case, otherwise SCALAR_INT_TYPE_MODE like for the INTEGER_TYPE case. The following patch instead just uses SCALAR_INT_TYPE_MODE for non-BLKmode TYPE_MODE and TYPE_SIZE_UNIT otherwise. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-01-19 Jakub Jelinek PR tree-optimization/113459 * tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def): Use TREE_INT_CST_LOW of TYPE_SIZE_UNIT rather than GET_MODE_SIZE of SCALAR_INT_TYPE_MODE if type has BLKmode. (vn_reference_lookup_3): Likewise. Formatting fix. * gcc.dg/bitint-73.c: New test. Jakub --- gcc/tree-ssa-sccvn.cc.jj 2024-01-03 11:51:42.361580881 +0100 +++ gcc/tree-ssa-sccvn.cc 2024-01-18 12:39:52.789606975 +0100 @@ -2287,7 +2287,12 @@ vn_walk_cb_data::push_partial_def (pd_da BITS_PER_UNIT - (maxsizei % BITS_PER_UNIT)); if (INTEGRAL_TYPE_P (type)) - sz = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)); + { + if (TYPE_MODE (type) != BLKmode) + sz = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)); + else + sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)); + } if (sz > needed_len) { memcpy (this_buffer + (sz - needed_len), buffer, needed_len); @@ -2967,8 +2972,10 @@ vn_reference_lookup_3 (ao_ref *ref, tree } else { - unsigned buflen = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (vr->type)) + 1; - if (INTEGRAL_TYPE_P (vr->type)) + unsigned buflen + = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (vr->type)) + 1; + if (INTEGRAL_TYPE_P (vr->type) + && TYPE_MODE (vr->type) != BLKmode) buflen = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (vr->type)) + 1; unsigned char *buf = XALLOCAVEC (unsigned char, buflen); memset (buf, TREE_INT_CST_LOW (gimple_call_arg (def_stmt, 1)), @@ -3165,7 +3172,12 @@ vn_reference_lookup_3 (ao_ref *ref, tree offset + maxsize - 1. */ HOST_WIDE_INT sz = maxsizei / BITS_PER_UNIT; if (INTEGRAL_TYPE_P (type)) - sz = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)); + { + if (TYPE_MODE (type) != BLKmode) + sz = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)); + else + sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)); + } amnt = ((unsigned HOST_WIDE_INT) offset2i + size2i - offseti - maxsizei) % BITS_PER_UNIT; if (amnt) --- gcc/testsuite/gcc.dg/bitint-73.c.jj 2024-01-18 12:29:07.586634031 +0100 +++ gcc/testsuite/gcc.dg/bitint-73.c 2024-01-18 12:28:42.406986342 +0100 @@ -0,0 +1,18 @@ +/* PR tree-optimization/113459 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c23 -O2" } */ + +#if __BITINT_MAXWIDTH__ >= 129 +# define N 129 +#else +# define N 63 +#endif + +_BitInt(N) a; + +_BitInt(N) +foo (void) +{ + __builtin_memset (&a, 6, sizeof a); + return a; +}