From 0661762fe86a0f0c126908b347ab91a1fcd69e2b Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 18 Dec 2015 16:40:44 +0100 Subject: [PATCH] gpu.c: remove minor code duplication In particular, the implementations of subtree_has_permutable_bands and has_any_permutable_node are almost identical. Implement the second in terms of the first. Signed-off-by: Sven Verdoolaege --- gpu.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gpu.c b/gpu.c index 7b9a0ed..757cc89 100644 --- a/gpu.c +++ b/gpu.c @@ -2383,17 +2383,33 @@ static isl_bool set_permutable(__isl_keep isl_schedule_node *node, void *user) return isl_bool_error; } +/* Does the subtree rooted at "node" have any suitably permutable band nodes? + * That is, does it have any nodes that are permutable and that + * have a least one coincident dimension? + */ +static int subtree_has_permutable_bands(__isl_keep isl_schedule_node *node) +{ + int any_parallelism = 0; + + if (isl_schedule_node_foreach_descendant_top_down(node, &set_permutable, + &any_parallelism) < 0 && + !any_parallelism) + return -1; + + return any_parallelism; +} + /* Does "schedule" contain any permutable band with at least one coincident * member? */ static int has_any_permutable_node(__isl_keep isl_schedule *schedule) { - int any_permutable = 0; + isl_schedule_node *root; + int any_permutable; - if (isl_schedule_foreach_schedule_node_top_down(schedule, - &set_permutable, &any_permutable) < 0 && - !any_permutable) - return -1; + root = isl_schedule_get_root(schedule); + any_permutable = subtree_has_permutable_bands(root); + isl_schedule_node_free(root); return any_permutable; } @@ -3839,22 +3855,6 @@ static __isl_give isl_schedule_node *mark_outer_permutable( return node; } -/* Does the subtree rooted at "node" have any suitably permutable band nodes? - * That is, does it have any nodes that are permutable and that - * have a least one coincident dimension? - */ -static int subtree_has_permutable_bands(__isl_keep isl_schedule_node *node) -{ - int any_parallelism = 0; - - if (isl_schedule_node_foreach_descendant_top_down(node, &set_permutable, - &any_parallelism) < 0 && - !any_parallelism) - return -1; - - return any_parallelism; -} - /* Mark all variables that are accessed by the statement instances in "domain" * and that are local to "prog" as requiring a declaration in the host code. */ -- 2.11.4.GIT