Message ID | ZcCUHdSLzNrlJqoh@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp726491dyb; Sun, 4 Feb 2024 23:54:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtuU9robZoQTorK9+biOEtojPF+pyWYzL05EXWV/Urj+r97iMkKdd1tR4t9bR0ymMI9N8S X-Received: by 2002:a05:620a:b44:b0:784:ba4:704d with SMTP id x4-20020a05620a0b4400b007840ba4704dmr12145003qkg.37.1707119688382; Sun, 04 Feb 2024 23:54:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707119688; cv=pass; d=google.com; s=arc-20160816; b=WYp6uOkBwmsqnH00SYntOTG4nurFBYTTTWw5Vp0ytow8d8cXJvuCy42gK5DaBhML2C vUWBjSZK9lSMJoXOIG2VQpJ07QwYPlliNqCSueoh3mAVc/QXww/gD74wkd/KZbemIkvb 9okeCKEWlHOmmudT+9vEpFsr57uLoWtJG2rxbhwGQ9UFM05slMO3hOafpDuPXuLAVk+M awWrpm0KvTdpyFjwXjaB91MME9HTcVlJYCQgbenm0kHIefUuDpeFm4FY10COOlDToWFO +ONSaMXLIc2/vcpGGt6+lJINcNZa2lGSOwyLqb4zcLGMvqNk1jxQ1b4HImvvI3YuL5QF IOAA== 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=TzVsysJb/fXxl8ocS0qOORruBNB4iQinzhnlGnKi2io=; fh=Xd+czuopaSYy0yTNgJy9CLazcj3J2gaFKM/OrOuNjZg=; b=ElISSxqeGRjaHUXSQgrOQPiTuRb5u4q4tWLHXblHH+4RXE7E/ta5zPEtxlWKAR8ru3 PIBKHBnpw3O0xDTRVogPkgHYrWj8r2WvGALNqK0K0tjIHs2a+PSfX+OA/zedYUmmiX32 7MbETGNJn2C/Am3ZkBN0zodXiixoMV01IYIspI0BbSW6ftOUo9osnTg/NK/WWHhEB7OH pR+WYkkr/+RpwT6uRoA9zLNSaMcbdGHktEzdwa+ZfjHKZN2uEkVS4Xm2VV1n64Njj0ZK 1oPgO1lpcIW4tCt+nZFI/tA84fl/B6ovGCWzcIm8GJnzpH/TQGQERuo+9ae07WU+wctE bY7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DsMm4P5Z; 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 X-Forwarded-Encrypted: i=1; AJvYcCVOTObyvcFnIelOKlrqGrt1JvtN356LwMXCftl10docY5bYZL06O+j+KElcJSiRS4vDDMn3kBdXMsq2VDMtr4B+tiAgOQ== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j11-20020a05620a410b00b007855eda538fsi6654757qko.459.2024.02.04.23.54.48 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 23:54:48 -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=DsMm4P5Z; 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 19C883858288 for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 07:54:48 +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 4961F3858CDB for <gcc-patches@gcc.gnu.org>; Mon, 5 Feb 2024 07:54:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4961F3858CDB 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 4961F3858CDB 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=1707119652; cv=none; b=FgNP0JEl4TYX+2TEthGxYipKXeHiTa9B6bLUVqdgCx3ZuLIbFPk17qhdMMxC7jFvfP8LumU2pMk+G53oSWWaqo7v0byEDYZQz99lj3ogZ3xrxP7PmX/Du3pA3bk3Fx8OTWX5fuwGmQUmix0I4rt2e9hH8BWWVFbbEYoZpC/LKDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707119652; c=relaxed/simple; bh=srgxFgDLS7pYpOLjTe5TC0C5AwJq9KFatYaka61681I=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Ltaa1qpAGUSjR0s0wU2IqwkEm8WSnIPuwQRDXJ6Oql3f+Igr7Ys60jOGWXYGNmMheYNYgGMOuCfMKyCzqYYqpUlepqRHFsPDPJCxZFlDw7Uc6R2Ja3gEYp4+qVsjsrwGPcYOgrRjLBSdoU9bDHEzUzJxN+v4cKK11ElNtkAuaUE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707119650; 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=TzVsysJb/fXxl8ocS0qOORruBNB4iQinzhnlGnKi2io=; b=DsMm4P5ZK+Z8X9G5l76JsLkCJ5pMgH+ofrsAxr/i+NKAnum6SwbLbpVSoYQPVJDi47ylLr LJcX0U5NKUq5nKvlGdPlt5H4e8/XsTGAQwvFVSIJBtmH0T49c0fSB8Gpxbnp8mBUlzmBxi mwnos63ELj7wFqy2ieF9w3ZdXDAdE90= 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-403-B8rFaNGrPoCLCvgjQHwemA-1; Mon, 05 Feb 2024 02:54:09 -0500 X-MC-Unique: B8rFaNGrPoCLCvgjQHwemA-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 11CEC29AC03B; Mon, 5 Feb 2024 07:54:09 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2E8A40C9444; Mon, 5 Feb 2024 07:54:08 +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 4157s6Tc319239 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 5 Feb 2024 08:54:06 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4157s5NK319238; Mon, 5 Feb 2024 08:54:05 +0100 Date: Mon, 5 Feb 2024 08:54:05 +0100 From: Jakub Jelinek <jakub@redhat.com> To: Richard Biener <rguenther@suse.de> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] lower-bitint: Remove single label _BitInt switches [PR113737] Message-ID: <ZcCUHdSLzNrlJqoh@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.8 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_H2, 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: 1790044734427495857 X-GMAIL-MSGID: 1790044734427495857 |
Series |
lower-bitint: Remove single label _BitInt switches [PR113737]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
Feb. 5, 2024, 7:54 a.m. UTC
Hi! The following testcase ICEs, because group_case_labels_stmt optimizes switch (a.0_7) <default: <L6> [50.00%], case 0: <L7> [50.00%], case 2: <L7> [50.00%]> where L7 block starts with __builtin_unreachable (); to switch (a.0_7) <default: <L6> [50.00%]> and single label GIMPLE_SWITCH is something the switch expansion refuses to lower: if (gimple_switch_num_labels (m_switch) == 1 || range_check_type (index_type) == NULL_TREE) return false; (range_check_type never returns NULL for BITINT_TYPE), but the gimple lowering pass relies on all large/huge _BitInt switches to be lowered by that pass. The following patch just removes those after making the single successor edge EDGE_FALLTHRU. I've done it even if !optimize just in case in case we'd end up with single case label from earlier passes. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-02-05 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/113737 * gimple-lower-bitint.cc (gimple_lower_bitint): If GIMPLE_SWITCH has just a single label, remove it and make single successor edge EDGE_FALLTHRU. * gcc.dg/bitint-84.c: New test. Jakub
Comments
On Mon, 5 Feb 2024, Jakub Jelinek wrote: > Hi! > > The following testcase ICEs, because group_case_labels_stmt optimizes > switch (a.0_7) <default: <L6> [50.00%], case 0: <L7> [50.00%], case 2: <L7> [50.00%]> > where L7 block starts with __builtin_unreachable (); to > switch (a.0_7) <default: <L6> [50.00%]> > and single label GIMPLE_SWITCH is something the switch expansion refuses to > lower: > if (gimple_switch_num_labels (m_switch) == 1 > || range_check_type (index_type) == NULL_TREE) > return false; > (range_check_type never returns NULL for BITINT_TYPE), but the gimple > lowering pass relies on all large/huge _BitInt switches to be lowered > by that pass. > > The following patch just removes those after making the single successor > edge EDGE_FALLTHRU. I've done it even if !optimize just in case in case > we'd end up with single case label from earlier passes. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. Richard. > 2024-02-05 Jakub Jelinek <jakub@redhat.com> > > PR tree-optimization/113737 > * gimple-lower-bitint.cc (gimple_lower_bitint): If GIMPLE_SWITCH > has just a single label, remove it and make single successor edge > EDGE_FALLTHRU. > > * gcc.dg/bitint-84.c: New test. > > --- gcc/gimple-lower-bitint.cc.jj 2024-02-02 11:30:05.801776658 +0100 > +++ gcc/gimple-lower-bitint.cc 2024-02-03 12:49:52.997777574 +0100 > @@ -5832,7 +5832,14 @@ gimple_lower_bitint (void) > > if (optimize) > group_case_labels_stmt (swtch); > - switch_statements.safe_push (swtch); > + if (gimple_switch_num_labels (swtch) == 1) > + { > + single_succ_edge (bb)->flags |= EDGE_FALLTHRU; > + gimple_stmt_iterator gsi = gsi_for_stmt (swtch); > + gsi_remove (&gsi, true); > + } > + else > + switch_statements.safe_push (swtch); > } > } > > --- gcc/testsuite/gcc.dg/bitint-84.c.jj 2024-02-03 12:56:08.153622744 +0100 > +++ gcc/testsuite/gcc.dg/bitint-84.c 2024-02-03 12:57:05.425835789 +0100 > @@ -0,0 +1,32 @@ > +/* PR tree-optimization/113737 */ > +/* { dg-do compile { target bitint } } */ > +/* { dg-options "-O2 -std=c23" } */ > + > +#if __BITINT_MAXWIDTH__ >= 129 > +_BitInt(129) a; > +#else > +_BitInt(63) a; > +#endif > + > +int b[1], c; > + > +int > +foo (void) > +{ > + switch (a) > + case 0: > + case 2: > + return 1; > + return 0; > +} > + > +void > +bar (int i) > +{ > + for (;; ++i) > + { > + c = b[i]; > + if (!foo ()) > + __asm__ (""); > + } > +} > > Jakub > >
--- gcc/gimple-lower-bitint.cc.jj 2024-02-02 11:30:05.801776658 +0100 +++ gcc/gimple-lower-bitint.cc 2024-02-03 12:49:52.997777574 +0100 @@ -5832,7 +5832,14 @@ gimple_lower_bitint (void) if (optimize) group_case_labels_stmt (swtch); - switch_statements.safe_push (swtch); + if (gimple_switch_num_labels (swtch) == 1) + { + single_succ_edge (bb)->flags |= EDGE_FALLTHRU; + gimple_stmt_iterator gsi = gsi_for_stmt (swtch); + gsi_remove (&gsi, true); + } + else + switch_statements.safe_push (swtch); } } --- gcc/testsuite/gcc.dg/bitint-84.c.jj 2024-02-03 12:56:08.153622744 +0100 +++ gcc/testsuite/gcc.dg/bitint-84.c 2024-02-03 12:57:05.425835789 +0100 @@ -0,0 +1,32 @@ +/* PR tree-optimization/113737 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c23" } */ + +#if __BITINT_MAXWIDTH__ >= 129 +_BitInt(129) a; +#else +_BitInt(63) a; +#endif + +int b[1], c; + +int +foo (void) +{ + switch (a) + case 0: + case 2: + return 1; + return 0; +} + +void +bar (int i) +{ + for (;; ++i) + { + c = b[i]; + if (!foo ()) + __asm__ (""); + } +}