From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62671 invoked by alias); 20 May 2019 14:04:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 62663 invoked by uid 89); 20 May 2019 14:04:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=our X-HELO: mail-lj1-f193.google.com Received: from mail-lj1-f193.google.com (HELO mail-lj1-f193.google.com) (209.85.208.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 May 2019 14:04:52 +0000 Received: by mail-lj1-f193.google.com with SMTP id h19so12618818ljj.4 for ; Mon, 20 May 2019 07:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=CY8KA9lsi0qiuizye2/WgwWL6+34vhd46h3FE8wzDtM=; b=L3mcCfu2r3yCqLnJVTXO1bU+NUwaepq682fXzQDHbdpdkZPhnac91InzuBgBj54v6U 4N8rZqXvUis033uH2DWnX2NWEX8PDeCTvN4qD4WXm2HQ0cHKeRyKTVUyKuiSibG/JhC2 rdJ6/yGXXL5ecb0LLaVurZHMNIDkHHzuGx2WZ5cFp9ayFjs2ASBN94vkJQjpDbSNyWah Eo9fu4CwX0gsVNGhcEBK2CGN4VComeuhiIMv+ke2E7gXyNz9Y+pOe61+d+MD5lZHuW+C gPNbwPAaRCDWMnk8yZhZwPOQx9JFt1q16O3CNZXxlNuOTrIr1GAjD6QqSN2fjg/LS/+b tkpg== MIME-Version: 1.0 References: <334e4382-d393-4a83-0fa6-abd80a949f44@redhat.com> In-Reply-To: From: Richard Biener Date: Mon, 20 May 2019 14:04:00 -0000 Message-ID: Subject: Re: [PATCH] Remove empty loop with assumed finiteness (PR tree-optimization/89713) To: Feng Xue OS Cc: "gcc-patches@gcc.gnu.org" , Jeff Law Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-05/txt/msg01254.txt.bz2 On Mon, May 20, 2019 at 4:00 PM Feng Xue OS w= rote: > > >> I specialized a CD-DCE pass, named CD-DCE2, and only in this pass, loo= p removal based on assumed finteness is performed. Please check the patch. > > > > Oh, but why not generally do this? > > It is nature that real finiteness of loop should override assumed one. As= you said, CD-DCE could be invocated as an early pass. At that time, we mig= ht make mistake deduction on finiteness for a loop whose bound is in form o= f variable, but could be transformed to constant by later optimizations. So= it is not "safe" to generally do this in CD-DCE. We need one late and spec= ific pass. I don't see how it is safe in a late pass when it is not safe in an earlier one. Optimization is imperfect - we could fail to remove an "obvious" never taken exit and still have a loop that appears to be finite according to our definition. The only way to define it would be if there was, at any point, an exit from the loop (and there it _may_ be exclude EH edges) then the loop is assumed to be finite. Richard. > Feng