Message ID | ZYVE5zMA/0hCcNxV@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp913840dyi; Fri, 22 Dec 2023 00:12:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQ1dHSUkHXlYumnjrjLHAE6c3Ieb+ksoJ/14/eCSHfSKWQiVXxmlbXNTiRpFYlEQ2NJm4c X-Received: by 2002:a05:6102:5788:b0:466:e1b6:b110 with SMTP id dh8-20020a056102578800b00466e1b6b110mr206128vsb.69.1703232778935; Fri, 22 Dec 2023 00:12:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703232778; cv=pass; d=google.com; s=arc-20160816; b=L9mUmtwJ9vO2dxZirK0PImZHTnZLFYP47efcpd2CkeS795qHDde1pQ2taXysw4VNIb ydSF2pP3eIwfQGwZqaIKc4jtfQASS4a2FDEdpt3YIb6UgM8bje3BHWoEb1dkjVWKi5ru 3S5EsTx2m09skP30sBlCFNwOWRLn0xY+yObz57mYrr3y/1Zp78egFww4uHprS89xRE7I YVAMiPL8inpMIHZ57NUEri2u8L7yyauZj6QeybWQLQEQ+6H1Obmekk8M9Xzq2Go6CC9D rvWVPR+Ay7iv9pzzKB6OPacFzXzh8zLoKYhxUsIRgWAW2fickY+ZALCHQwZuVtr7F8Ip SWyA== 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=zwq1/qcwLA6J+6pXa+fjx25+1HrvcPQCDzlQxeXwHGY=; fh=FCjeRajqaQYHMkQtfIia8KT5yBac53mYOLLyJhYG/AY=; b=OD1eEqwQmIbryRCUR18y03i86E7pYyLe+x3O8PRylUKv7Gr/1vXXsBx+KPmPqors4Z MrNhk3egL8LruIGM3q7ntVZZo34dUvjAOvZ5M+zdgVR7hOdsYIZlisZlZVZcwGVAzPja qWaJ62ZEgvkAeq8a1z0PG00T4SGgpnAj4aNbxshyN0/z3ZzXyTR9kEEKgziaeu7t1HVX 8Z4wafx36LT/l70c5UAkbJqGwPGQRDE93uEuklSC02OIg0yGN5t0JBM0yni365KO1skX lDKTQfgszm7Q3skNW5SR6WVZkR9k5R7arwvlJOEC/WJPatnWuL0SZq5GAy5SGNfGoEDW TlNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VZIvrV0J; 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 x19-20020ac85f13000000b00425497dcb86si3958630qta.387.2023.12.22.00.12.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 00:12:58 -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=VZIvrV0J; 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 A800D386189D for <ouuuleilei@gmail.com>; Fri, 22 Dec 2023 08:12:58 +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 567A43858D3C for <gcc-patches@gcc.gnu.org>; Fri, 22 Dec 2023 08:12:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 567A43858D3C 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 567A43858D3C 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=1703232752; cv=none; b=F/Th8nNAuEVvx+Ibz+gaXRrOREqQ3NptZKtd21sLIPBuIdbfC7DnUZNKBceJeMAItBYHDmC8GJiiCDGL3ptN1DpDkzI3tJHZ2tJLKfy7kYunOcRHYCEJS0Lt+RE1cAxmFGqHN5g6FbRj1miIVWVn1BxZRWROBR1FvVNzdDKjBeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703232752; c=relaxed/simple; bh=VZrNYZ8uAqpBA8glZFhW1hrlM9PpenGFjNrMFq3DnOg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Ig0NW4k0ExWmKSt7CNVcvpV7tZRC3jeWJDpjndImEpAOcGUPHpfOQS/evXRJAjY5RGvenrnXrAuKJwmY77SMTsHnpiTYrRVzCJy0ESsruUriOe5fQDnO6GxE4EpXUqzVIOp2oVh8VxI9XCKAcDb8tXo999mikgJT4LGDhOfOO1s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703232751; 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=zwq1/qcwLA6J+6pXa+fjx25+1HrvcPQCDzlQxeXwHGY=; b=VZIvrV0JYToRCqIFO28wzh0T6906MqbmsGPJoFEeA86pzQGdgvMwe/2KEHMt+x5gU+UnJS 7vCI6ssv6n5TtS/bTZGhe8Mkk0JtLMx03yd0RJdrgjw70V5vZbevmDCbSJS19XpD2VGNfs r8OSZD/5IpHfuxw2gRQM+ZhfVvRE6IY= 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-614-3HZAFL5ANFCIocj1-EB8tw-1; Fri, 22 Dec 2023 03:12:27 -0500 X-MC-Unique: 3HZAFL5ANFCIocj1-EB8tw-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 10ACB85A589; Fri, 22 Dec 2023 08:12:27 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C93E340C6EB9; Fri, 22 Dec 2023 08:12: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 3BM8CO95241222 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 22 Dec 2023 09:12:24 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3BM8CNv5241221; Fri, 22 Dec 2023 09:12:23 +0100 Date: Fri, 22 Dec 2023 09:12:23 +0100 From: Jakub Jelinek <jakub@redhat.com> To: Richard Biener <rguenther@suse.de> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] lower-bitint: Fix handle_cast ICE [PR113102] Message-ID: <ZYVE5zMA/0hCcNxV@tucnak> 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-Type: text/plain; charset=us-ascii 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785969014741062577 X-GMAIL-MSGID: 1785969014741062577 |
Series |
lower-bitint: Fix handle_cast ICE [PR113102]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
Dec. 22, 2023, 8:12 a.m. UTC
Hi! My recent change to use m_data[save_data_cnt] instead of m_data[save_data_cnt + 1] when inside of a loop (m_bb is non-NULL) broke the following testcase. When we create a PHI node on the loop using prepare_data_in_out, both m_data[save_data_cnt{, + 1}] are computed and the fix was right, but there are also cases when we in a loop (m_bb non-NULL) emit a nested cast with too few limbs and then just use constant indexes for all accesses - in that case only m_data[save_data_cnt + 1] is initialized and m_data[save_data_cnt] is NULL. In those cases, we want to use the former. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-12-22 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/113102 * gimple-lower-bitint.cc (bitint_large_huge::handle_cast): Only use m_data[save_data_cnt] if it is non-NULL. * gcc.dg/bitint-58.c: New test. Jakub
Comments
> Am 22.12.2023 um 09:12 schrieb Jakub Jelinek <jakub@redhat.com>: > > Hi! > > My recent change to use m_data[save_data_cnt] instead of > m_data[save_data_cnt + 1] when inside of a loop (m_bb is non-NULL) > broke the following testcase. When we create a PHI node on the loop > using prepare_data_in_out, both m_data[save_data_cnt{, + 1}] are > computed and the fix was right, but there are also cases when we in > a loop (m_bb non-NULL) emit a nested cast with too few limbs and > then just use constant indexes for all accesses - in that case > only m_data[save_data_cnt + 1] is initialized and m_data[save_data_cnt] > is NULL. In those cases, we want to use the former. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok > 2023-12-22 Jakub Jelinek <jakub@redhat.com> > > PR tree-optimization/113102 > * gimple-lower-bitint.cc (bitint_large_huge::handle_cast): Only > use m_data[save_data_cnt] if it is non-NULL. > > * gcc.dg/bitint-58.c: New test. > > --- gcc/gimple-lower-bitint.cc.jj 2023-12-21 11:13:32.000000000 +0100 > +++ gcc/gimple-lower-bitint.cc 2023-12-21 13:28:56.953120687 +0100 > @@ -1491,7 +1491,7 @@ bitint_large_huge::handle_cast (tree lhs > m_data_cnt = tree_to_uhwi (m_data[save_data_cnt + 2]); > if (TYPE_UNSIGNED (rhs_type)) > t = build_zero_cst (m_limb_type); > - else if (m_bb) > + else if (m_bb && m_data[save_data_cnt]) > t = m_data[save_data_cnt]; > else > t = m_data[save_data_cnt + 1]; > --- gcc/testsuite/gcc.dg/bitint-58.c.jj 2023-12-21 13:33:25.882383838 +0100 > +++ gcc/testsuite/gcc.dg/bitint-58.c 2023-12-21 13:32:54.408821172 +0100 > @@ -0,0 +1,31 @@ > +/* PR tree-optimization/113102 */ > +/* { dg-do compile { target bitint } } */ > +/* { dg-options "-std=c23 -O2" } */ > + > +_BitInt(3) a; > +#if __BITINT_MAXWIDTH__ >= 4097 > +_BitInt(8) b; > +_BitInt(495) c; > +_BitInt(513) d; > +_BitInt(1085) e; > +_BitInt(4096) f; > + > +void > +foo (void) > +{ > + a -= (_BitInt(4097)) d >> b; > +} > + > +void > +bar (void) > +{ > + __builtin_sub_overflow ((_BitInt(767)) c >> e, 0, &a); > +} > + > +void > +baz (void) > +{ > + _BitInt(768) x = (_BitInt(257))f; > + b /= x >> 0 / 0; /* { dg-warning "division by zero" } */ > +} > +#endif > > Jakub >
--- gcc/gimple-lower-bitint.cc.jj 2023-12-21 11:13:32.000000000 +0100 +++ gcc/gimple-lower-bitint.cc 2023-12-21 13:28:56.953120687 +0100 @@ -1491,7 +1491,7 @@ bitint_large_huge::handle_cast (tree lhs m_data_cnt = tree_to_uhwi (m_data[save_data_cnt + 2]); if (TYPE_UNSIGNED (rhs_type)) t = build_zero_cst (m_limb_type); - else if (m_bb) + else if (m_bb && m_data[save_data_cnt]) t = m_data[save_data_cnt]; else t = m_data[save_data_cnt + 1]; --- gcc/testsuite/gcc.dg/bitint-58.c.jj 2023-12-21 13:33:25.882383838 +0100 +++ gcc/testsuite/gcc.dg/bitint-58.c 2023-12-21 13:32:54.408821172 +0100 @@ -0,0 +1,31 @@ +/* PR tree-optimization/113102 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c23 -O2" } */ + +_BitInt(3) a; +#if __BITINT_MAXWIDTH__ >= 4097 +_BitInt(8) b; +_BitInt(495) c; +_BitInt(513) d; +_BitInt(1085) e; +_BitInt(4096) f; + +void +foo (void) +{ + a -= (_BitInt(4097)) d >> b; +} + +void +bar (void) +{ + __builtin_sub_overflow ((_BitInt(767)) c >> e, 0, &a); +} + +void +baz (void) +{ + _BitInt(768) x = (_BitInt(257))f; + b /= x >> 0 / 0; /* { dg-warning "division by zero" } */ +} +#endif