From patchwork Fri Sep 22 09:37:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 817419 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-462763-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SseFncwE"; dkim-atps=neutral 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 3xz7h52jQ8z9s5L for ; Fri, 22 Sep 2017 19:38:12 +1000 (AEST) 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=pnEdeqer7yFDbk17yoA+bgxoZi4O4khMZGea43k61QIGafRWsz0CM yOrOMgU/8SAHtFK9B5mFLHGgFpavZrdU/NAflr1viXHDQKSaMEIlDX3JJDq2So9X Hfl01/PWuMUuMXB9MbQnzHIiUXmuWz4QQ+tpE9SttLzhEguIM5YfIk= 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=PrBYAiyXrHKrN5BlNaiVefeVZTU=; b=SseFncwEfILUqn85iCFU F/K9b5ufW3MaZieMiFX6CmEY2Dok+A538lIbyJNyD7DH6e2Ja/f8y+8AR0sOvDaT eCLIvGhUtTt7CrqAPTukGTHVvTXmWPVtk/fK+yl9nEDGwk2uLqsqOmOvlcBzfmoR v+F2L6XJAxSJO2nsCu6JLqY= Received: (qmail 113527 invoked by alias); 22 Sep 2017 09:38:03 -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 113518 invoked by uid 89); 22 Sep 2017 09:38:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS 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; Fri, 22 Sep 2017 09:38:01 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3BC17ABE4 for ; Fri, 22 Sep 2017 09:37:59 +0000 (UTC) Date: Fri, 22 Sep 2017 11:37:59 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][GRAPHITE] Simplify move_sese_in_condition Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 This re-implements it avoding the need to recompute dominators and in a much simpler way. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress, SPEC CPU 2006 is happy. Richard. 2017-09-22 Richard Biener * sese.c: Include cfganal.h. (if_region_set_false_region): Remove. (create_if_region_on_edge): Likewise. (move_sese_in_condition): Re-implement without destroying dominators. Index: gcc/sese.c =================================================================== --- gcc/sese.c (revision 253090) +++ gcc/sese.c (working copy) @@ -40,8 +40,9 @@ along with GCC; see the file COPYING3. #include "cfgloop.h" #include "tree-data-ref.h" #include "tree-scalar-evolution.h" -#include "sese.h" #include "tree-ssa-propagate.h" +#include "cfganal.h" +#include "sese.h" /* For a USE in BB, if BB is outside REGION, mark the USE in the LIVEOUTS set. */ @@ -333,99 +334,6 @@ get_false_edge_from_guard_bb (basic_bloc return NULL; } -/* Sets the false region of an IF_REGION to REGION. */ - -static void -if_region_set_false_region (ifsese if_region, sese_info_p region) -{ - free_dominance_info (CDI_DOMINATORS); - - basic_block condition = if_region_get_condition_block (if_region); - edge false_edge = get_false_edge_from_guard_bb (condition); - basic_block dummy = false_edge->dest; - edge entry_region = region->region.entry; - edge exit_region = region->region.exit; - basic_block before_region = entry_region->src; - basic_block last_in_region = exit_region->src; - hashval_t hash = htab_hash_pointer (exit_region); - loop_exit **slot - = current_loops->exits->find_slot_with_hash (exit_region, hash, NO_INSERT); - bool latch_p - = exit_region->dest->loop_father->latch == exit_region->src; - - entry_region->flags = false_edge->flags; - false_edge->flags = exit_region->flags; - - redirect_edge_pred (entry_region, condition); - redirect_edge_pred (exit_region, before_region); - redirect_edge_pred (false_edge, last_in_region); - redirect_edge_succ (false_edge, single_succ (dummy)); - delete_basic_block (dummy); - - exit_region->flags = EDGE_FALLTHRU; - - region->region.exit = false_edge; - - free (if_region->false_region); - if_region->false_region = region; - - if (slot) - { - struct loop_exit *loop_exit = ggc_cleared_alloc (); - - memcpy (loop_exit, *((struct loop_exit **) slot), - sizeof (struct loop_exit)); - current_loops->exits->clear_slot (slot); - - hashval_t hash = htab_hash_pointer (false_edge); - slot = current_loops->exits->find_slot_with_hash (false_edge, hash, - INSERT); - loop_exit->e = false_edge; - *slot = loop_exit; - false_edge->src->loop_father->exits->next = loop_exit; - } - if (latch_p) - exit_region->dest->loop_father->latch = before_region; - - calculate_dominance_info (CDI_DOMINATORS); -} - -/* Creates an IFSESE with CONDITION on edge ENTRY. */ - -static ifsese -create_if_region_on_edge (edge entry, tree condition) -{ - edge e; - edge_iterator ei; - sese_info_p sese_region = XNEW (struct sese_info_t); - sese_info_p true_region = XNEW (struct sese_info_t); - sese_info_p false_region = XNEW (struct sese_info_t); - ifsese if_region = XNEW (struct ifsese_s); - edge exit = create_empty_if_region_on_edge (entry, condition); - - if_region->region = sese_region; - if_region->region->region.entry = entry; - if_region->region->region.exit = exit; - - FOR_EACH_EDGE (e, ei, entry->dest->succs) - { - if (e->flags & EDGE_TRUE_VALUE) - { - true_region->region.entry = e; - true_region->region.exit = single_succ_edge (e->dest); - if_region->true_region = true_region; - } - else if (e->flags & EDGE_FALSE_VALUE) - { - false_region->region.entry = e; - false_region->region.exit = single_succ_edge (e->dest); - if_region->false_region = false_region; - } - } - - return if_region; -} - /* Moves REGION in a condition expression: | if (1) | ; @@ -436,14 +344,32 @@ create_if_region_on_edge (edge entry, tr ifsese move_sese_in_condition (sese_info_p region) { - gcc_assert (! dom_info_available_p (cfun, CDI_POST_DOMINATORS)); + basic_block region_entry_dest = region->region.entry->dest; basic_block pred_block = split_edge (region->region.entry); - ifsese if_region; + basic_block merge_block = split_edge (region->region.exit); - region->region.entry = single_succ_edge (pred_block); - if_region = create_if_region_on_edge (single_pred_edge (pred_block), - integer_one_node); - if_region_set_false_region (if_region, region); + edge true_edge = make_edge (pred_block, merge_block, EDGE_TRUE_VALUE); + edge false_edge = find_edge (pred_block, region_entry_dest); + false_edge->flags &= ~EDGE_FALLTHRU; + false_edge->flags |= EDGE_FALSE_VALUE; + gimple_stmt_iterator gsi = gsi_last_bb (pred_block); + gcond *cond = gimple_build_cond (NE_EXPR, integer_one_node, integer_zero_node, + NULL_TREE, NULL_TREE); + gsi_insert_after (&gsi, cond, GSI_CONTINUE_LINKING); + if (dom_info_available_p (CDI_DOMINATORS)) + set_immediate_dominator (CDI_DOMINATORS, merge_block, pred_block); + + ifsese if_region = XNEW (ifsese_s); + if_region->region = XCNEW (sese_info_t); + if_region->true_region = XCNEW (sese_info_t); + if_region->false_region = XCNEW (sese_info_t); + if_region->region->region.entry = single_pred_edge (pred_block); + if_region->region->region.exit = single_succ_edge (merge_block); + if_region->false_region->region.entry = false_edge; + if_region->false_region->region.exit = region->region.exit; + if_region->true_region->region.entry = true_edge; + if_region->true_region->region.exit + = single_succ_edge (split_edge (true_edge)); return if_region; }