From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32148 invoked by alias); 25 Jun 2014 14:09:01 -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 32138 invoked by uid 89); 25 Jun 2014 14:08:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 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; Wed, 25 Jun 2014 14:08:59 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 20337AD60; Wed, 25 Jun 2014 14:08:56 +0000 (UTC) Date: Wed, 25 Jun 2014 14:09:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: law@redhat.com Subject: [PATCH] Fix parts of PR61607 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2014-06/txt/msg02017.txt.bz2 This removes prematurely killing loops during jump threading and moves it to a spot where we know we didn't cancel the jump thread. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Ok? Thanks, Richard. 2014-06-25 Richard Biener PR tree-optimization/61607 * tree-ssa-threadupdate.c (ssa_redirect_edges): Cancel the loop if we redirected its latch edge. (thread_block_1): Do not cancel loops prematurely. Index: gcc/tree-ssa-threadupdate.c =================================================================== *** gcc/tree-ssa-threadupdate.c (revision 211978) --- gcc/tree-ssa-threadupdate.c (working copy) *************** ssa_redirect_edges (struct redirection_d *** 764,769 **** --- 764,777 ---- if ((*path)[1]->type != EDGE_COPY_SRC_JOINER_BLOCK) EDGE_SUCC (rd->dup_blocks[0], 0)->count += e->count; + /* If we redirect a loop latch edge cancel its loop. */ + if (e->src == e->src->loop_father->latch) + { + e->src->loop_father->header = NULL; + e->src->loop_father->latch = NULL; + loops_state_set (LOOPS_NEED_FIXUP); + } + /* Redirect the incoming edge (possibly to the joiner block) to the appropriate duplicate block. */ e2 = redirect_edge_and_branch (e, rd->dup_blocks[0]); *************** thread_block_1 (basic_block bb, bool nol *** 844,850 **** edge e, e2; edge_iterator ei; ssa_local_info_t local_info; - struct loop *loop = bb->loop_father; /* To avoid scanning a linear array for the element we need we instead use a hash table. For normal code there should be no noticeable --- 852,857 ---- *************** thread_block_1 (basic_block bb, bool nol *** 853,884 **** redirection_data = new hash_table (EDGE_COUNT (bb->succs)); - /* If we thread the latch of the loop to its exit, the loop ceases to - exist. Make sure we do not restrict ourselves in order to preserve - this loop. */ - if (loop->header == bb) - { - e = loop_latch_edge (loop); - vec *path = THREAD_PATH (e); - - if (path - && (((*path)[1]->type == EDGE_COPY_SRC_JOINER_BLOCK && joiners) - || ((*path)[1]->type == EDGE_COPY_SRC_BLOCK && !joiners))) - { - for (unsigned int i = 1; i < path->length (); i++) - { - edge e2 = (*path)[i]->e; - - if (loop_exit_edge_p (loop, e2)) - { - loop->header = NULL; - loop->latch = NULL; - loops_state_set (LOOPS_NEED_FIXUP); - } - } - } - } - /* Record each unique threaded destination into a hash table for efficient lookups. */ FOR_EACH_EDGE (e, ei, bb->preds) --- 860,865 ----