From patchwork Fri Dec 8 07:41:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 175661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5299945vqy; Thu, 7 Dec 2023 23:41:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8AjcEoUUIkmr58KBESRz+ylVtnadAW82eQ1cg6275lU50aPNWzDnBgXEuQf539te8LvsR X-Received: by 2002:a05:620a:3b15:b0:77f:3ca:9274 with SMTP id tl21-20020a05620a3b1500b0077f03ca9274mr2424478qkn.100.1702021312000; Thu, 07 Dec 2023 23:41:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702021311; cv=pass; d=google.com; s=arc-20160816; b=bwLCbQ8o+heYmpZ68s0QDVluwPteVSBzPlWYuVI0WYE7Phgg7kRpHt9S8b0pHKBl01 Yw+qu4BXWnQR6MBI1Nhm3S5su8HteBZJVety5WeAGG9sWIWa77pLSpkQ9rx0X2jCUgSR +4TSuTC15TBPs4uVWtgFJLnodL/TiEG3xhl9AKBSkUMoQI6gT+lfwtJ8rVempvEyVtQW +GcPnWeN3oWfY/uoTntun30fdnOeEeHlblzN9wj+pwmDdNaaNBQB3iYLi0BmnSnVXAn+ WDrmwUHKhzRzWq94NgulcORE469n0QXXr983mF9B/A4nejG9sRPamtf81pWQg1tFdkt/ XCoQ== 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=6zsFTZ7qmjaPbEqgXqL+CtmXxs2mVBNXtI/aTsTtAJw=; fh=9hOpCP1FmRJTJfu3F/pFo5U7ivAqrwPaAPaPtHpx0ng=; b=EXAnAoD8OZNZCGEcxKHCeMtryEfOGG6WAp3c0Z4iLO6Rc8DiWpVqRwlDufXIPivXNO Cf9pqlP7kMfRZ9LKgOZuivO4/lujx0tNJ5+BSkIHVTbdGmLeUau7HK64yX72ZV17TY+B hdj8ylPk9P0XhuuYZhmxAqbllmMOQHcdOBZS1XS21XEU/F1FI82n/LH0GYKOJl3F4MMc OLsWwMqchUoyCKHSd9eFKCRtQ35qq0TPe7VAOg7yrjWRMvCZd4fbdl3MIBAS5MyguZ// I+r9GuUuMFMG3pYpjQBk7JVKhX6M1xsThIG1d5t4DBPOpqrP/lYny4hnmuMgLeDMZJCu vV0w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i8NKzKhy; 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 r7-20020a05620a298700b0077f11e354efsi1613667qkp.415.2023.12.07.23.41.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 23:41:51 -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=i8NKzKhy; 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 C2BD83858023 for ; Fri, 8 Dec 2023 07:41:51 +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 5EF2F3858C60 for ; Fri, 8 Dec 2023 07:41:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5EF2F3858C60 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 5EF2F3858C60 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=1702021290; cv=none; b=eu5pOagnUHPqkM2ofjDYsAmrMzztuN/tTKr8VYFUFqZ6Ztjg2VgFTlwjXu41AZtr03VaPgqdOrKFdTRqGCTFcszuIg96R/pGMES3PDPsvZyXshlwOMZEwhDA+IUPNWaZ+khYIIHnI3Aae6Ra2sQPkORL6U1H+J7EoF5U6juhBj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702021290; c=relaxed/simple; bh=fakZVWWm1POVspXyv6WfjtW65W3ICeValmYPHyrZbTw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=f5JXC70lvSs9RtDaqh3dJonptT4KbpSaWTshjVP6UqUYO45Yh+RQzVHxxJvBoQ2NtNGS4yQfMTFEIQgnqE0QRdBcmWneApfl9RCC7khFb66qjs+qFST9EKpWd9O/egTMegaLzV5sF2NHoCBT7SGUabFItw/UXVMZVN9nPaWtt2k= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702021286; 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=6zsFTZ7qmjaPbEqgXqL+CtmXxs2mVBNXtI/aTsTtAJw=; b=i8NKzKhybHNAPhXkHT1b7rUJRsLh+SIdKTr95SxUh0YVlanBKxlqkl2kAgWVD/Qr2I3fl2 atenIcOFdyUZjDPRqN4MDSXepKqUdgDEdCPBPoIRClZxU6XcM1og2G1XalYiBAKCONp7L4 v0rp+1AHYzczNw7uaXB+yfBVayUljco= 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-589-RiKsfeRiN3um7b5JOG5tJA-1; Fri, 08 Dec 2023 02:41:22 -0500 X-MC-Unique: RiKsfeRiN3um7b5JOG5tJA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 8EA943804517; Fri, 8 Dec 2023 07:41:22 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.157]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 52999492BE6; Fri, 8 Dec 2023 07:41:22 +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 3B87fJoC2911162 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 8 Dec 2023 08:41:20 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3B87fJbN2911161; Fri, 8 Dec 2023 08:41:19 +0100 Date: Fri, 8 Dec 2023 08:41:18 +0100 From: Jakub Jelinek To: Andrew MacLeod , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] vr-values: Avoid ICEs on large _BitInt cast to floating point [PR112901] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784698698817608504 X-GMAIL-MSGID: 1784698698817608504 Hi! For casts from integers to floating point, simplify_float_conversion_using_ranges uses SCALAR_INT_TYPE_MODE and queries optabs on the optimization it wants to make. That doesn't really work for large/huge BITINT_TYPE, those have BLKmode which is not scalar int mode. Querying an optab is not useful for that either. I think it is best to just skip this optimization for those bitints, after all, bitint lowering uses ranges already to determine minimum precision for bitint operands of the integer to float casts. Bootstrapped/regrtested on x86_64-linux and i686-linux, ok for trunk? 2023-12-08 Jakub Jelinek PR tree-optimization/112901 * vr-values.cc (simplify_using_ranges::simplify_float_conversion_using_ranges): Return false if rhs1 has BITINT_TYPE type with BLKmode TYPE_MODE. * gcc.dg/bitint-51.c: New test. Jakub --- gcc/vr-values.cc.jj 2023-09-06 17:28:24.240977329 +0200 +++ gcc/vr-values.cc 2023-12-07 14:34:36.935121459 +0100 @@ -1656,6 +1656,11 @@ simplify_using_ranges::simplify_float_co || vr.undefined_p ()) return false; + /* The code below doesn't work for large/huge _BitInt, nor is really + needed for those, bitint lowering does use ranges already. */ + if (TREE_CODE (TREE_TYPE (rhs1)) == BITINT_TYPE + && TYPE_MODE (TREE_TYPE (rhs1)) == BLKmode) + return false; /* First check if we can use a signed type in place of an unsigned. */ scalar_int_mode rhs_mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs1)); if (TYPE_UNSIGNED (TREE_TYPE (rhs1)) --- gcc/testsuite/gcc.dg/bitint-51.c.jj 2023-12-07 15:10:20.500384705 +0100 +++ gcc/testsuite/gcc.dg/bitint-51.c 2023-12-07 15:09:54.159750006 +0100 @@ -0,0 +1,14 @@ +/* PR tree-optimization/112901 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2" } */ + +float f; +#if __BITINT_MAXWIDTH__ >= 256 +_BitInt(256) i; + +void +foo (void) +{ + f *= 4 * i; +} +#endif