From patchwork Tue Oct 11 04:46:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1909908wrs; Mon, 10 Oct 2022 21:47:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XhGwnaNRhCvQPuvKBNC8pWmF+C5OnKLWTHZAWxHDlx19tBc8J2tgFuyvz5Zg1KHNnVv9O X-Received: by 2002:a05:6402:168c:b0:458:5b8b:afd2 with SMTP id a12-20020a056402168c00b004585b8bafd2mr20662606edv.357.1665463647914; Mon, 10 Oct 2022 21:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665463647; cv=none; d=google.com; s=arc-20160816; b=ixN1D3/c0jU4rQ44/+lkc6x9HhLUnchRE/cCpbmVYFY1LfA3bLKyDIIgKH8z9qlNsD BciK7cyEjxNLff3F7D8Sat8T1lqu38Mr1IOV5k6axc75Den6mlQQ69n1hfoq70Yb8le5 OejeUrYdLHh92yKqMFcwsw0C7p+FVpOqjQNv4JYrTskSQzaTtXQi3lUN2c0TI5yPnnPC lTBS19vvKekWYGCHOT9xhWRVnI5opJSNDxv3bjmuZwovHSoD+QxXNdgOx0SyiyFthn1C NJ82EWb5SItKNQTF6rHJG1DtYcBixh+vMTX+QpW+wjLvqQ3bmgdAmYNfcjLp7UZSfALH U2ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :content-language:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=W0d0r9ZDO/OL4V95Ii93gjDtgQP6dnJxA83okTO0RDc=; b=gmlriej86yNh/8+W99mZp/siwE1vqPvHb5t9hsj2sc6rIj5+Xd4Qqk0WJkqtfnQZKf bcsKU2QxYBBfnuYDFqeckH+voeAGjTmY+8EeHQQIzbOsY97hzD5qn4Dv0mLYYc/U4XNr azI5TCExAcbyTI4Wz7235xFRyC1q5IiX/ABm+TziPOnAOJe2DcDAYK5rbql+5ceshtvr SR5aywuTLo8Wul75w46Z9zrB32NzloZ4ao0F068TMMzQq7K2Yb+5UKeu0GV/Z3Is/sKV W3oBA7MQnkZU0zEQ66M/iEMRTfbwNC7XbnwB430Tl7o2FG5HWp77kc9fLH8ZfJxJQROt UjlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=W9Dm3tbD; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gb9-20020a170907960900b0078db6f5f499si5833078ejc.796.2022.10.10.21.47.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 21:47:27 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=W9Dm3tbD; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3096A385735E for ; Tue, 11 Oct 2022 04:47:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3096A385735E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665463641; bh=W0d0r9ZDO/OL4V95Ii93gjDtgQP6dnJxA83okTO0RDc=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=W9Dm3tbD08HA8f6AxNvyUPtUKqA+Gv3lyQeM6XKnFar1ZcB17d/ZtDt5sM5+Pq3/z mFPNhvj4uNmzJTfewUhlPcUGH0W84wgSb8XO0TyVANmB4ELXaeKtfuCM9C7NK6ifuU qL+C47qwjrlW2GvnTEucDzjMfyhrSU9Df64Pv/Dg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 696013858C2D for ; Tue, 11 Oct 2022 04:46:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 696013858C2D Received: by mail-pj1-x102e.google.com with SMTP id b15so11501957pje.1 for ; Mon, 10 Oct 2022 21:46:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:from:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W0d0r9ZDO/OL4V95Ii93gjDtgQP6dnJxA83okTO0RDc=; b=Udd3doV9LPwCJ60otUWKwErOkHqTDgnVsRTLAZNPVP0H9yFYEJ1v5AP0bine8asoan MMPCXOvoXtKAIPrOI+Z4pdPf3xF5ctlHBinet5lYi2DGAvRrpx8BfQpuOGpBg6MYDOe0 kKTeI41LcsV5pxNGMNwda5RqdGzFMjEqPLjxB+5vqXwBdSXTSnLh2/3YEx4aU56G8ms1 tJWwiQV6c15j5FD8KuJ5d7MnfK19Uykdsm9sozCl/f4zlc2HVJlKoU3DS91sZlFlyrlU 45/KHAZGW2TApiYYjZBBtkvCwvab9jNPsYipsVJjtOElWYUjQI5uQ7HpzBizfYr3kgkJ +s3A== X-Gm-Message-State: ACrzQf1tDgFEVm/ZmtuUKr2hLNCf6wQIFRaVRvxREg9j6aKXzs3FvlM3 44KJHfyktpqf8flntblLxLHVJTjQVoaoZA== X-Received: by 2002:a17:903:120d:b0:179:d027:66f0 with SMTP id l13-20020a170903120d00b00179d02766f0mr22350911plh.61.1665463596881; Mon, 10 Oct 2022 21:46:36 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id o8-20020a170902d4c800b00179c81f6693sm7524061plg.264.2022.10.10.21.46.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Oct 2022 21:46:36 -0700 (PDT) Message-ID: Date: Mon, 10 Oct 2022 22:46:35 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Content-Language: en-US Subject: [committed] [PR rtl-optimization/107182] Clear EDGE_CROSSING for jump->ret optimization To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jeff Law via Gcc-patches From: Jeff Law Reply-To: Jeff Law Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746365209923890441?= X-GMAIL-MSGID: =?utf-8?q?1746365209923890441?= When turning a jump to a return into a return, we need to clear EDGE_CROSSING of the fallthru edge to prevent a checking failure. I considered not applying the transformation when the edge has EDGE_CROSSING set, but it still seems like we ought to eliminate the unnecessary jump in that case. Bootstrapped and regression tested on x86_64.  Also did a profiled bootstrap and regression test on x86_64. Installing on the trunk. Jeff commit db24bdc743cf23ea12d2dcf8254d86ab366bb46d Author: Jeff Law Date: Tue Oct 11 00:44:26 2022 -0400 [PR rtl-optimization/107182] Clear EDGE_CROSSING for jump->ret optimization When turning a jump to a return into a return, we need to clear EDGE_CROSSING of the fallthru edge to prevent a checking failure. I considered not applying the transformation when the edge has EDGE_CROSSING set, but it still seems like we ought to eliminate the unnecessary jump in that case. gcc/ PR rtl-optimization/107182 * cfgrtl.cc (fixup_reorder_chain): When optimizing a jump to a return, clear EDGE_CROSSING on the appropriate edge. diff --git a/gcc/cfgrtl.cc b/gcc/cfgrtl.cc index 281a432f6a6..f31941a61f9 100644 --- a/gcc/cfgrtl.cc +++ b/gcc/cfgrtl.cc @@ -4055,6 +4055,7 @@ fixup_reorder_chain (void) ret_label = PATTERN (ret); dest = EXIT_BLOCK_PTR_FOR_FN (cfun); + e_fall->flags &= ~EDGE_CROSSING; /* E_FALL->dest might become unreachable as a result of replacing the jump with a return. So arrange to remove unreachable blocks. */