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: 58627 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C97C385740E for ; Tue, 11 Oct 2022 04:47:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C97C385740E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665463627; bh=W0d0r9ZDO/OL4V95Ii93gjDtgQP6dnJxA83okTO0RDc=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=XJ7sceeYXqdhH+2aIofrd3FcytyUPra9XY/044/YtLEa/7H7cJoJUEUYXVF/HM6t7 0wMnQKhii4pvJYOueboavuU0OgxTe2+Be62YJm5GEfqlkXegTyxgPTby/ehX8TvLvB ETKDUho/6tUELugdIMkEl0d+4WhtLL8J4VwJgP7Y= 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-Google-Smtp-Source: AMsMyM5XaLzF7s6TW9FOxF2vXUGTDXFkUZBfzhc314Sn7fBAsTRhFYEf0bpDAacWoWc1UKb4Enr/tA== 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. */