From patchwork Tue Sep 4 09:22:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 181532 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]) by ozlabs.org (Postfix) with SMTP id C00112C0085 for ; Tue, 4 Sep 2012 19:25:34 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1347355535; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=pfHfk8GfG8i/JhbSPWUe fK3xLXg=; b=j13tHRqzljhSgiS+Llz3nE2anLLLqlGd8SIf49AXz9cCGYG9iCGX Rvzfc8zfNR9nqkmdC5fPZK+4aHaf7E2uGcCiFlhRWtkBylPJNe12CHZA6WQ78lLS no5yicjPJvrLYTH4jchUvUVgSED3JWtkq0/uHj2NSWjNP6yxgnsyW6A= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=rJx4zH493wwSzTKqru24LnsJ89l7oTmSxPunzz0gDcqw4LUPtxxw87Q+jQ6HFO 8erNgO/Ya3xxcay1N2inpRieC2IQB/wZDs+f/Fh6EhOUTXB+yjWX0/KRn9NUDBtq oS4a9QflgrT+Agk3Acarqhxmsy/7iWioU6d1UNSPcqUbk=; Received: (qmail 10927 invoked by alias); 4 Sep 2012 09:25:31 -0000 Received: (qmail 10913 invoked by uid 22791); 4 Sep 2012 09:25:30 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 04 Sep 2012 09:25:18 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 91DB09FB23 for ; Tue, 4 Sep 2012 11:25:16 +0200 (CEST) Date: Tue, 4 Sep 2012 11:22:35 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR54458 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 This fixes PR54458 where DOM jump threading turns a loop into one with multiple latches but does not mark it so. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2012-09-04 Richard Guenther PR tree-optimization/54458 * tree-ssa-threadupdate.c (thread_through_loop_header): If we turn the loop into one with multiple latches mark it so. * gcc.dg/torture/pr54458.c: New testcase. Index: gcc/tree-ssa-threadupdate.c =================================================================== --- gcc/tree-ssa-threadupdate.c (revision 190889) +++ gcc/tree-ssa-threadupdate.c (working copy) @@ -1037,11 +1037,21 @@ thread_through_loop_header (struct loop } free (bblocks); + /* If the new header has multiple latches mark it so. */ + FOR_EACH_EDGE (e, ei, loop->header->preds) + if (e->src->loop_father == loop + && e->src != loop->latch) + { + loop->latch = NULL; + loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES); + } + /* Cancel remaining threading requests that would make the loop a multiple entry loop. */ FOR_EACH_EDGE (e, ei, header->preds) { edge e2; + if (e->aux == NULL) continue; Index: gcc/testsuite/gcc.dg/torture/pr54458.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr54458.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr54458.c (working copy) @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +unsigned int a, b, c; + +void +foo (unsigned int x) +{ + do + { + if (a == 0 ? 1 : 1 % a) + for (; b; b--) + lab:; + else + while (x) + ; + if (c) + goto lab; + } + while (1); +}