From patchwork Mon Jun 19 15:06:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 777820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wrvT748SJz9s8V for ; Tue, 20 Jun 2017 01:06:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="py3yJ9gB"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=kq0vIws/H7JPJbg2+3ytYB3+UK36TYH4IQae1BnPcaFdDOZmwyAcw XrtdgEuhIAIDzsE0JqhT/ERfLymuZ1oYLbzfKlCVlC+AcuKkf7jNa/fxtAHOt8Az eR7xRqLi/4/EAwDXX0IAeeycf53XH6VcTdwXCkgvw8XWk7C98tU2uA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=WHS+vrf6eGiHOLQ3wyyMExOmDgA=; b=py3yJ9gBkJpIe7O72yKc wWvRtTLE1Vz1w4HFA0xOIMxol8DwZ2WKaAKLJI1m38YTk9vYzU7xw/zZQc3zSHjO ADEGhan019BNAFpR9SZoJbNUX5DUX388nWn8zXOk4Yp2/2Q3JQEziN9PpdiPcumB XkWUhMgSxwSsarMGkbmmv9w= Received: (qmail 36466 invoked by alias); 19 Jun 2017 15:06:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 36445 invoked by uid 89); 19 Jun 2017 15:06:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Jun 2017 15:06:33 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A262AAB09 for ; Mon, 19 Jun 2017 15:06:36 +0000 (UTC) Date: Mon, 19 Jun 2017 17:06:36 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR81118 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2017-06-19 Richard Biener PR middle-end/81118 * tree-cfgcleanup.c (cleanup_tree_cfg_noloop): Clear niter estimates if we changed anything. * gcc.dg/torture/pr81118.c: New testcase. Index: gcc/tree-cfgcleanup.c =================================================================== --- gcc/tree-cfgcleanup.c (revision 249358) +++ gcc/tree-cfgcleanup.c (working copy) @@ -839,7 +839,12 @@ cleanup_tree_cfg_noloop (void) timevar_pop (TV_TREE_CLEANUP_CFG); if (changed && current_loops) - loops_state_set (LOOPS_NEED_FIXUP); + { + /* Removing edges and/or blocks may make recorded bounds refer + to stale GIMPLE stmts now, so clear them. */ + free_numbers_of_iterations_estimates (cfun); + loops_state_set (LOOPS_NEED_FIXUP); + } return changed; } Index: gcc/testsuite/gcc.dg/torture/pr81118.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr81118.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr81118.c (working copy) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-w" } */ + +int a[7], b; +int c() +{ + int d, e; + for (; d; d++) + if (a[d]) + if (b) + return; + else if (d >= e) + return 0; +}