From patchwork Thu Jul 24 10:09:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gareev X-Patchwork-Id: 373358 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 E359B1401EC for ; Thu, 24 Jul 2014 20:09:57 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=C4TP/QC9Vq+yi3ZhopEiVTNnUCctc02b6O7b10Z4zIf wm1hJXPIZ1+27mLjjfbZ4Hu7od3lH1/p23ivt+/UJlsBYsTBENZJnxzYCkCbS3x/ WAOUhS9/RQ2E94BtdqSX3NXCz+9eBG6YD09OcMUFj3Rcw/0PUbUNqc/Oy49uZH2E = 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 :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=TSZX0AZvkU2H2GLFzdZUqZAmtFM=; b=ycy20AVLeKNqGLX/J QhwfpeepgYFhGTwnijcyiOotzRdOrp7YsIiM/PAe2ifWlKqi0pIMr8O0cDpSwtLL jTeRiAUyCa7KAcmGCCSgwJX5n7erLhdFgpZsOT4W5rw7HZcWhZFxaWAbfWiM07U5 8Cx1q2KG9XN94iuhI1vVXWh1vQ= Received: (qmail 23192 invoked by alias); 24 Jul 2014 10:09:38 -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 23124 invoked by uid 89); 24 Jul 2014 10:09:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yh0-f49.google.com Received: from mail-yh0-f49.google.com (HELO mail-yh0-f49.google.com) (209.85.213.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 24 Jul 2014 10:09:36 +0000 Received: by mail-yh0-f49.google.com with SMTP id b6so1676156yha.8 for ; Thu, 24 Jul 2014 03:09:34 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.236.35.198 with SMTP id u46mr11567946yha.54.1406196574592; Thu, 24 Jul 2014 03:09:34 -0700 (PDT) Received: by 10.170.91.134 with HTTP; Thu, 24 Jul 2014 03:09:34 -0700 (PDT) Date: Thu, 24 Jul 2014 16:09:34 +0600 Message-ID: Subject: [GSoC] generation of Gimple code from isl_ast_node_if From: Roman Gareev To: Tobias Grosser Cc: Mircea Namolaru , gcc-patches@gcc.gnu.org I've attached the patch, which contains generation of Gimple code from isl_ast_node_if. However, I've found out a problem. When I'm trying to generate Gimple code from, for example, the following ISL AST: { for (int c1 = 0; c1 <= 49; c1 += 1) { S_6(c1); if (c1 <= 48) { S_3(c1); if (c1 >= 24) S_4(c1); S_5(c1); } } S_7(); } the pointer to Gimple basic block of S_3's poly basic block is NULL. Could you please advise me possible reasons of this issue? The source code of the example: int foo () { int i, res = 0; for (i = 0; i < 50; i++) { if (i >= 25) res += i; } return res; } extern void abort (); int main (void) { int res = foo (); if (res != 1225) abort (); return 0; } --- Cheers, Roman Gareev. Index: gcc/graphite-isl-ast-to-gimple.c =================================================================== --- gcc/graphite-isl-ast-to-gimple.c (revision 212922) +++ gcc/graphite-isl-ast-to-gimple.c (working copy) @@ -636,6 +636,42 @@ return next_e; } +/* Creates a new if region corresponding to ISL's cond. */ + +static edge +graphite_create_new_guard (edge entry_edge, __isl_take isl_ast_expr *if_cond, + ivs_params &ip) +{ + tree type = + build_nonstandard_integer_type (graphite_expression_type_precision, 0); + tree cond_expr = gcc_expression_from_isl_expression (type, if_cond, ip); + edge exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr); + return exit_edge; +} + +/* Translates an isl_ast_node_if to Gimple. */ + +static edge +translate_isl_ast_node_if (loop_p context_loop, + __isl_keep isl_ast_node *node, + edge next_e, ivs_params &ip) +{ + gcc_assert (isl_ast_node_get_type (node) == isl_ast_node_if); + isl_ast_expr *if_cond = isl_ast_node_if_get_cond (node); + edge last_e = graphite_create_new_guard (next_e, if_cond, ip); + + edge true_e = get_true_edge_from_guard_bb (next_e->dest); + isl_ast_node *then_node = isl_ast_node_if_get_then (node); + translate_isl_ast (context_loop, then_node, true_e, ip); + isl_ast_node_free (then_node); + + edge false_e = get_false_edge_from_guard_bb (next_e->dest); + isl_ast_node *else_node = isl_ast_node_if_get_else (node); + translate_isl_ast (context_loop, else_node, false_e, ip); + isl_ast_node_free (else_node); + return last_e; +} + /* Translates an ISL AST node NODE to GCC representation in the context of a SESE. */ @@ -653,7 +689,8 @@ next_e, ip); case isl_ast_node_if: - return next_e; + return translate_isl_ast_node_if (context_loop, node, + next_e, ip); case isl_ast_node_user: return translate_isl_ast_node_user (node, next_e, ip);