From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39469 invoked by alias); 15 Jan 2016 17:15: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 39233 invoked by uid 89); 15 Jan 2016 17:15:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=analyse, bitmap_iterator, harmful, BEGIN X-HELO: mail-ob0-f194.google.com Received: from mail-ob0-f194.google.com (HELO mail-ob0-f194.google.com) (209.85.214.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 15 Jan 2016 17:14:55 +0000 Received: by mail-ob0-f194.google.com with SMTP id tr5so35218568obc.2 for ; Fri, 15 Jan 2016 09:14:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=qIJBJbC5kmamOOm9EGyQ95EdHc8iajpg7xGTCq+X6xU=; b=Hdhnc1xm8GOEC/mRHxycHi+YX9f6oLGg5aa+kWqtBNtydOTwFv4I9q6CX5Ta6waBeU 0Du2bCwBjlyiCJhQB1sw1rISvQhRoy5a0EjEu8D2ECSqdKJHiLqVeBS5JYLG9dN/l3RP JotoIUg8k0d2YrVHaiZ7eKz15G2BLmosnd2VqYIyyEHJpEf2uasLgFoXqJLYIaSV+sa3 Ft8d2N20wVjbSA5NRW3dNO+yNcJQ3oM2B+YFqkBQNEPLRFem6/8i3mGfi9BqmoQT8szB tPnDWh/QfUvyQR1TsX61SPFTeRKgLcB18tj4UYoVSOeiKK9NwYA7FCErCuyP6OUyk3t/ CukQ== X-Gm-Message-State: ALoCoQlOQOIkA4ds/b+2am8VQVNmRznnQfphiEmd/09P6ZeZO1ufhN8UqYZuKIkdK8UUc4Hchpxbsa6ky4NWsFchpvWsn815rQ== X-Received: by 10.182.214.40 with SMTP id nx8mr9692069obc.20.1452878093554; Fri, 15 Jan 2016 09:14:53 -0800 (PST) Received: from bo.sarc.sas (65-36-6-125.static.grandenetworks.net. [65.36.6.125]) by smtp.gmail.com with ESMTPSA id r63sm6618774oia.13.2016.01.15.09.14.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jan 2016 09:14:53 -0800 (PST) From: Sebastian Pop X-Google-Original-From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: hiraditya@msn.com, sebpop@gmail.com, richard.guenther@gmail.com, Sebastian Pop Subject: [PATCH 07/15] check that all loops are valid in the combined region Date: Fri, 15 Jan 2016 17:15:00 -0000 Message-Id: <1452878086-19297-7-git-send-email-sebpop@gmail.com> In-Reply-To: <1452878086-19297-1-git-send-email-sebpop@gmail.com> References: <1452878086-19297-1-git-send-email-sebpop@gmail.com> X-SW-Source: 2016-01/txt/msg01100.txt.bz2 From: Sebastian Pop the bug was exposed by rewriting an if condition into an assert in the computation of the loop iteration domains. * graphite-scop-detection.c (loop_is_valid_scop): Renamed loop_is_valid_in_scop. (scop_detection::harmful_stmt_in_region): Renamed harmful_loop_in_region. Call loop_is_valid_in_scop. --- gcc/graphite-scop-detection.c | 56 ++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index ad11227..e004185 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -554,7 +554,7 @@ public: region of code that can be represented in the polyhedral model. SCOP defines the region we analyse. */ - bool loop_is_valid_scop (loop_p loop, sese_l scop) const; + bool loop_is_valid_in_scop (loop_p loop, sese_l scop) const; /* Return true when BEGIN is the preheader edge of a loop with a single exit END. */ @@ -597,7 +597,7 @@ public: Limit the number of bbs between adjacent loops to PARAM_SCOP_MAX_NUM_BBS_BETWEEN_LOOPS. */ - bool harmful_stmt_in_region (sese_l scop) const; + bool harmful_loop_in_region (sese_l scop) const; /* Return true only when STMT is simple enough for being handled by Graphite. This depends on SCOP, as the parameters are initialized relatively to @@ -777,8 +777,9 @@ scop_detection::merge_sese (sese_l first, sese_l second) const if (!second) return first; - DEBUG_PRINT (dp << "[try-merging-sese] s1: "; print_sese (dump_file, first); - dp << "[try-merging-sese] s2: "; + DEBUG_PRINT (dp << "[scop-detection] try merging sese s1: "; + print_sese (dump_file, first); + dp << "[scop-detection] try merging sese s2: "; print_sese (dump_file, second)); /* Assumption: Both the sese's should be at the same loop depth or one scop @@ -807,7 +808,7 @@ scop_detection::merge_sese (sese_l first, sese_l second) const sese_l combined (entry, exit); - DEBUG_PRINT (dp << "checking combined sese: "; + DEBUG_PRINT (dp << "[scop-detection] checking combined sese: "; print_sese (dump_file, combined)); /* FIXME: We could iterate to find the dom which dominates pdom, and pdom @@ -849,7 +850,7 @@ scop_detection::merge_sese (sese_l first, sese_l second) const } /* Analyze all the BBs in new sese. */ - if (harmful_stmt_in_region (combined)) + if (harmful_loop_in_region (combined)) return invalid_sese; DEBUG_PRINT (dp << "[merged-sese] s1: "; print_sese (dump_file, combined)); @@ -877,7 +878,7 @@ scop_detection::build_scop_depth (sese_l s, loop_p loop) return s; } - if (!loop_is_valid_scop (loop, s2)) + if (!loop_is_valid_in_scop (loop, s2)) return build_scop_depth (invalid_sese, loop->next); return build_scop_breadth (s2, loop); @@ -954,7 +955,7 @@ scop_detection::can_represent_loop (loop_p loop, sese_l scop) defines the region we analyse. */ bool -scop_detection::loop_is_valid_scop (loop_p loop, sese_l scop) const +scop_detection::loop_is_valid_in_scop (loop_p loop, sese_l scop) const { if (!scop) return false; @@ -1008,7 +1009,7 @@ scop_detection::add_scop (sese_l s) /* Do not add scops with only one loop. */ if (region_has_one_loop (s)) { - DEBUG_PRINT (dp << "[scop-detection-fail] Discarding one loop SCoP.\n"; + DEBUG_PRINT (dp << "[scop-detection-fail] Discarding one loop SCoP: "; print_sese (dump_file, s)); return; } @@ -1016,7 +1017,7 @@ scop_detection::add_scop (sese_l s) if (get_exit_bb (s) == EXIT_BLOCK_PTR_FOR_FN (cfun)) { DEBUG_PRINT (dp << "[scop-detection-fail] " - << "Discarding SCoP exiting to return."; + << "Discarding SCoP exiting to return: "; print_sese (dump_file, s)); return; } @@ -1029,7 +1030,7 @@ scop_detection::add_scop (sese_l s) remove_intersecting_scops (s); scops.safe_push (s); - DEBUG_PRINT (dp << "Adding SCoP "; print_sese (dump_file, s)); + DEBUG_PRINT (dp << "[scop-detection] Adding SCoP: "; print_sese (dump_file, s)); } /* Return true when a statement in SCOP cannot be represented by Graphite. @@ -1038,7 +1039,7 @@ scop_detection::add_scop (sese_l s) PARAM_SCOP_MAX_NUM_BBS_BETWEEN_LOOPS. */ bool -scop_detection::harmful_stmt_in_region (sese_l scop) const +scop_detection::harmful_loop_in_region (sese_l scop) const { basic_block exit_bb = get_exit_bb (scop); basic_block entry_bb = get_entry_bb (scop); @@ -1056,6 +1057,7 @@ scop_detection::harmful_stmt_in_region (sese_l scop) const = get_dominated_to_depth (CDI_DOMINATORS, entry_bb, depth); int i; basic_block bb; + bitmap loops = BITMAP_ALLOC (NULL); FOR_EACH_VEC_ELT (dom, i, bb) { DEBUG_PRINT (dp << "Visiting bb_" << bb->index << "\n"); @@ -1072,16 +1074,42 @@ scop_detection::harmful_stmt_in_region (sese_l scop) const if (bb->flags & BB_IRREDUCIBLE_LOOP) { dom.release (); + BITMAP_FREE (loops); return true; } - if (harmful_stmt_in_bb (scop, bb)) + /* Collect all loops in the current region. */ + loop_p loop = bb->loop_father; + if (loop_in_sese_p (loop, scop)) + bitmap_set_bit (loops, loop->num); + else { - dom.release (); + /* We only check for harmful statements in basic blocks not part of + any loop fully contained in the scop: other bbs are checked below + in loop_is_valid_in_scop. */ + if (harmful_stmt_in_bb (scop, bb)) + return true; + } + + } + + /* Go through all loops and check that they are still valid in the combined + scop. */ + unsigned j; + bitmap_iterator bi; + EXECUTE_IF_SET_IN_BITMAP (loops, 0, j, bi) + { + loop_p loop = (*current_loops->larray)[j]; + gcc_assert (loop->num == (int) j); + + if (!loop_is_valid_in_scop (loop, scop)) + { + BITMAP_FREE (loops); return true; } } + BITMAP_FREE (loops); dom.release (); return false; } -- 2.5.0