From patchwork Thu Nov 27 09:50:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 415418 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 A02411401B5 for ; Thu, 27 Nov 2014 20:56:24 +1100 (AEDT) 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=Rhp7xwaU3ZLWxI7TE5tVrk7x4bez0gmiWUoCQe4ANNAfZwaIaOA7F gY09UM98wQDPVZEA+8eOG1vd8hO8BHtf0gGHd1int9319mHQDuO8hycgdH/neAtk hNurJtIsemH7JLUDrabdJtOu/GXZsTaz2FwDCsbZW07Cu9ctJXHcsE= 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=vdh+81gotItvWehOFJXaXBQ1yYA=; b=nx2KoMHJwhO/bxgCewZ/ b0mrPp2CVZ13hlH9khWdNOC2u70Ti40JwZWQjIGXPAgtIy0J2SIoDcTQm2aTng/o XjfJ2VjFz5kW+5o9NGtueqTNd3b5D7lkc8EKZRGqaMsZIvMr2Op8O8AvkjPeNOrx 9/Q5kPCts2LeEv9lOVMEZNA= Received: (qmail 1396 invoked by alias); 27 Nov 2014 09:56:18 -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 1384 invoked by uid 89); 27 Nov 2014 09:56:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 27 Nov 2014 09:56:16 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A5917AC11 for ; Thu, 27 Nov 2014 09:56:13 +0000 (UTC) Date: Thu, 27 Nov 2014 10:50:03 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR64083 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 The following fixes an omission from when I introduced the mark_loop_for_removal abstraction. thread_through_all_blocks still uses the old way of killing a loop. The following patch fixes this by not killing it at all (it's just likely that the loop will break and a loop-fixup is scheduled anyway if we change the CFG and that fixup will deal with this just fine). Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2014-11-26 Richard Biener PR tree-optimization/64083 * tree-ssa-threadupdate.c (thread_through_all_blocks): Do not forcibly mark loop for removal the wrong way. * gcc.dg/torture/pr64083.c: New testcase. Index: gcc/tree-ssa-threadupdate.c =================================================================== --- gcc/tree-ssa-threadupdate.c (revision 218078) +++ gcc/tree-ssa-threadupdate.c (working copy) @@ -2428,16 +2428,8 @@ thread_through_all_blocks (bool may_peel /* Our path is still valid, thread it. */ if (e->aux) { - struct loop *loop = (*path)[0]->e->dest->loop_father; - if (thread_block ((*path)[0]->e->dest, false)) - { - /* This jump thread likely totally scrambled this loop. - So arrange for it to be fixed up. */ - loop->header = NULL; - loop->latch = NULL; - e->aux = NULL; - } + e->aux = NULL; else { delete_jump_thread_path (path); Index: gcc/testsuite/gcc.dg/torture/pr64083.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr64083.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr64083.c (working copy) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int a, b; +void +fn1 () +{ + int c = 0; + while (b) + { + switch (c) + case 1: + fn1 (); + if (a) + c = 1; + b = 0; + } +}