Message ID | ZZkSSMmtFTYYKjAE@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:37c1:b0:101:2151:f287 with SMTP id y1csp12400dyq; Sat, 6 Jan 2024 00:45:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJikQ3OFwDJx2truWF4hfu3Wcdg8oh8lf1FG25FKBSNJtzrE6WiFL+f04pXji5AWNVNMTl X-Received: by 2002:a05:620a:b0d:b0:781:4143:b980 with SMTP id t13-20020a05620a0b0d00b007814143b980mr635120qkg.61.1704530727439; Sat, 06 Jan 2024 00:45:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704530727; cv=pass; d=google.com; s=arc-20160816; b=0B9gL0hAJo0ANnQwSPfCfBd1D4vIY1pgDxDhuTykLoPGB571k4YMEWFfYhI3+ReBfb 9RSzE3SFay5Mtm6/NU/BNQxtA6gnTSTCAVHImMFY1vQhaHamyZd22pFxBzRd5J1ehlFa 3OLXoVL3Zust5gir6LMbBQ2zDefRG9rqOVQCgGXyWaXa744atV+Q/zoR33xc3DkywlA6 f6Vv09ui3Gg+cilHWsIp1oEj81SlGfpSVyapa/In1NwM9g+F2JnEkHjf1CHOmK2b0YdA 3AV5W42F1n8UvUqs/S5umhDJKLcOs6lTksvZ8+mChUODDRp2wCjYOMmR1e3g1hTR+0dn JNSQ== 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=8E5yeBl4olIeEftBfvowmQ+W8+e2/AdbmCRJGgNtKKs=; fh=FCjeRajqaQYHMkQtfIia8KT5yBac53mYOLLyJhYG/AY=; b=Z5gL1uVlUvJ6wOnI+tITn4czD8gE2ePkDaKwMxiXnSeibb4o2aPunGEivZyGxv0GGD ZvFfTVi1WJ14aq6LH+Ob6SQPoghXrWBRWuqiHIiGht5moKLJcuJub2xasL5OsE71lPey AkCiWXAm/IP6nR1DJ8Y5KbjUBV1w3ML9UxneKyl1b0xiCgcmz7vWxmdeK+wlYzwb+8YS 05yCKsjFAm4/eCbtpRooj5utlVUp0SBEZ3T+ir6e52+lZ+kxpBuCpWUBFezt2VzfukVF tTLPZJWgGheF0cJTgBqTnq9uoWndNkxsplmISklBPTA9Ddv3te+wjJHY6E/6/iCbzkEx 3XoA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="B/HjgWAk"; 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 h6-20020a05620a244600b007816603ecb4si3752482qkn.60.2024.01.06.00.45.27 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 00:45:27 -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="B/HjgWAk"; 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 0004A3858D3C for <ouuuleilei@gmail.com>; Sat, 6 Jan 2024 08:45:26 +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 6D06D3858D1E for <gcc-patches@gcc.gnu.org>; Sat, 6 Jan 2024 08:42:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D06D3858D1E 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 6D06D3858D1E 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=1704530528; cv=none; b=EmeReNd1RkL4g/r8NVi9O/wTMuZDLj4ivjYv95rXR1ml7PrHQg8Y+HcAHWWcwEvR4tvkMxmk212aKKIl+MOxsBTDGz/6j9RRO+vdvhbXmanvjrMhLKZh7L3uIz23V2XsAZpZgtO7DTHIcu7/3fLdCT5nYFTqZVlZvGL9djVtSu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704530528; c=relaxed/simple; bh=dmmzKmbJGkYf1Txgt8qcmj4ns1vhCR/oSnrRt+9jLuo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=WMYOAByRWk/+q5PFtxzDQMgEvGyz3gaSCl+aLKUnYFzQZzTRJQ0Dyjgl5+6uc21S70ByuFglrhmlH3tTnl1b/Wp8y3pijl3W7qaRyo/0buXbvGn99+DKu9RE/YdO0QVwgfBe2K9m9YgGuzO8cXpgKNe/FWnf2U++7LXtkCAAmHk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704530520; 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=8E5yeBl4olIeEftBfvowmQ+W8+e2/AdbmCRJGgNtKKs=; b=B/HjgWAk0VIs0urNp3ayH5OLejpYtvPdQfR2QxI+hSh0tE6CKyPcsY6wUV+pJYFBCX3wxL TkUDFw4a92B477kFjqVJTVjBCEGaedAs10OGMNqVzc8VN5s9Cc5muQQpgSIJFCZMs5ku7N 0N8peezMMhqpxUAR7Q+tq0rcTqoOMk8= 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-163-XdB-lKklPr-9uzC5CiP9SQ-1; Sat, 06 Jan 2024 03:41:49 -0500 X-MC-Unique: XdB-lKklPr-9uzC5CiP9SQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 52D2D803915; Sat, 6 Jan 2024 08:41:49 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 164B8492BC8; Sat, 6 Jan 2024 08:41:48 +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 4068fjjJ2724823 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 6 Jan 2024 09:41:45 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4068fipx2724822; Sat, 6 Jan 2024 09:41:44 +0100 Date: Sat, 6 Jan 2024 09:41:44 +0100 From: Jakub Jelinek <jakub@redhat.com> To: Richard Biener <rguenther@suse.de> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] gimplify: Fix ICE in recalculate_side_effects [PR113228] Message-ID: <ZZkSSMmtFTYYKjAE@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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=-4.7 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 <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: 1787330012393642701 X-GMAIL-MSGID: 1787330012393642701 |
Series |
gimplify: Fix ICE in recalculate_side_effects [PR113228]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
Jan. 6, 2024, 8:41 a.m. UTC
Hi! The following testcase ICEs during regimplificatgion since the addition of (convert (eqne zero_one_valued_p@0 INTEGER_CST@1)) simplification. That simplification is novel in the sense that in gimplify_expr it can turn an expression (comparison in particular) into a SSA_NAME. Normally when gimplify_expr sees originally a SSA_NAME, it does case SSA_NAME: /* Allow callbacks into the gimplifier during optimization. */ ret = GS_ALL_DONE; break; and doesn't try to recalculate side effects because of that, but in this case gimplify_expr normally enters the: default: switch (TREE_CODE_CLASS (TREE_CODE (*expr_p))) { case tcc_comparison: then does *expr_p = gimple_boolify (*expr_p); and then *expr_p = fold_convert_loc (input_location, org_type, *expr_p); with this new match.pd simplification turns that tcc_comparison class into SSA_NAME. Unlike the outer SSA_NAME handling though, this falls through into recalculate_side_effects (*expr_p); dont_recalculate: break; but unfortunately recalculate_side_effects doesn't handle SSA_NAME and ICEs on it. SSA_NAMEs don't ever have TREE_SIDE_EFFECTS set on those, so the following patch fixes it by handling it similarly to the tcc_constant case. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-01-06 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/113228 * gimplify.cc (recalculate_side_effects): Do nothing for SSA_NAMEs. * gcc.c-torture/compile/pr113228.c: New test. Jakub
Comments
On Sat, 6 Jan 2024, Jakub Jelinek wrote: > Hi! > > The following testcase ICEs during regimplificatgion since the addition of > (convert (eqne zero_one_valued_p@0 INTEGER_CST@1)) > simplification. That simplification is novel in the sense that in > gimplify_expr it can turn an expression (comparison in particular) into > a SSA_NAME. Normally when gimplify_expr sees originally a SSA_NAME, it does > case SSA_NAME: > /* Allow callbacks into the gimplifier during optimization. */ > ret = GS_ALL_DONE; > break; > and doesn't try to recalculate side effects because of that, but in this > case gimplify_expr normally enters the: > default: > switch (TREE_CODE_CLASS (TREE_CODE (*expr_p))) > { > case tcc_comparison: > then does > *expr_p = gimple_boolify (*expr_p); > and then > *expr_p = fold_convert_loc (input_location, > org_type, *expr_p); > with this new match.pd simplification turns that tcc_comparison class > into SSA_NAME. Unlike the outer SSA_NAME handling though, this falls > through into > recalculate_side_effects (*expr_p); > > dont_recalculate: > break; > but unfortunately recalculate_side_effects doesn't handle SSA_NAME and ICEs > on it. > SSA_NAMEs don't ever have TREE_SIDE_EFFECTS set on those, so the following > patch fixes it by handling it similarly to the tcc_constant case. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. Richard. > 2024-01-06 Jakub Jelinek <jakub@redhat.com> > > PR tree-optimization/113228 > * gimplify.cc (recalculate_side_effects): Do nothing for SSA_NAMEs. > > * gcc.c-torture/compile/pr113228.c: New test. > > --- gcc/gimplify.cc.jj 2024-01-03 11:51:40.744603324 +0100 > +++ gcc/gimplify.cc 2024-01-05 13:32:34.351336320 +0100 > @@ -3344,6 +3344,9 @@ recalculate_side_effects (tree t) > return; > > default: > + if (code == SSA_NAME) > + /* No side-effects. */ > + return; > gcc_unreachable (); > } > } > --- gcc/testsuite/gcc.c-torture/compile/pr113228.c.jj 2024-01-05 13:27:42.876330301 +0100 > +++ gcc/testsuite/gcc.c-torture/compile/pr113228.c 2024-01-05 13:27:22.503609458 +0100 > @@ -0,0 +1,17 @@ > +/* PR tree-optimization/113228 */ > + > +int a, b, c, d, i; > + > +void > +foo (void) > +{ > + int k[3] = {}; > + int *l = &a; > + for (d = 0; c; c--) > + for (i = 0; i <= 9; i++) > + { > + for (b = 1; b <= 4; b++) > + k[0] = k[0] == 0; > + *l |= k[d]; > + } > +} > > Jakub > >
--- gcc/gimplify.cc.jj 2024-01-03 11:51:40.744603324 +0100 +++ gcc/gimplify.cc 2024-01-05 13:32:34.351336320 +0100 @@ -3344,6 +3344,9 @@ recalculate_side_effects (tree t) return; default: + if (code == SSA_NAME) + /* No side-effects. */ + return; gcc_unreachable (); } } --- gcc/testsuite/gcc.c-torture/compile/pr113228.c.jj 2024-01-05 13:27:42.876330301 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr113228.c 2024-01-05 13:27:22.503609458 +0100 @@ -0,0 +1,17 @@ +/* PR tree-optimization/113228 */ + +int a, b, c, d, i; + +void +foo (void) +{ + int k[3] = {}; + int *l = &a; + for (d = 0; c; c--) + for (i = 0; i <= 9; i++) + { + for (b = 1; b <= 4; b++) + k[0] = k[0] == 0; + *l |= k[d]; + } +}