avoid generation of empty guards in trivial cases
authorAditya Kumar <aditya.k7@samsung.com>
Wed, 21 Oct 2015 18:53:35 +0000 (18:53 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Wed, 21 Oct 2015 18:53:35 +0000 (18:53 +0000)
We used to insert a trivial integer_onep condition around loops we know have
more than an iteration.  This patch avoids generating those conditions.

* graphite-isl-ast-to-gimple.c (graphite_create_new_loop_guard): Do not call
create_empty_if_region_on_edge when cond_expr is true.
(translate_isl_ast_node_for): Check whether a guard has been generated.

Co-Authored-By: Sebastian Pop <s.pop@samsung.com>
From-SVN: r229137

gcc/ChangeLog
gcc/graphite-isl-ast-to-gimple.c

index 8b4735d4626c795067d52fad00031a8ca03a476c..1bad16db4b1c987c36167d58144faee31ae35ac0 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-21  Aditya Kumar  <aditya.k7@samsung.com>
+           Sebastian Pop  <s.pop@samsung.com>
+
+       * graphite-isl-ast-to-gimple.c (graphite_create_new_loop_guard): Do not call
+       create_empty_if_region_on_edge when cond_expr is true.
+       (translate_isl_ast_node_for): Check whether a guard has been generated.
+
 2015-10-21  Aditya Kumar  <aditya.k7@samsung.com>
 
        * graphite-poly.h (struct dr_info): Added invalid_alias_set number.
index 7f99bce8c1f9f4573daeaeb99147efdca0410353..de2847743e15d724f51aa1b450b20d288ed8143f 100644 (file)
@@ -707,7 +707,10 @@ graphite_create_new_loop_guard (edge entry_edge,
       cond_expr = fold_build2 (LT_EXPR, boolean_type_node, *lb, ub_one);
     }
 
-  exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
+  if (integer_onep (cond_expr))
+    exit_edge = entry_edge;
+  else
+    exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
 
   return exit_edge;
 }
@@ -723,10 +726,14 @@ translate_isl_ast_node_for (loop_p context_loop, __isl_keep isl_ast_node *node,
   tree type, lb, ub;
   edge last_e = graphite_create_new_loop_guard (next_e, node, &type,
                                                &lb, &ub, ip);
-  edge true_e = get_true_edge_from_guard_bb (next_e->dest);
 
-  translate_isl_ast_for_loop (context_loop, node, true_e,
-                             type, lb, ub, ip);
+  if (last_e == next_e)
+    /* There was no guard generated.  */
+    return translate_isl_ast_for_loop (context_loop, node, last_e,
+                                      type, lb, ub, ip);
+
+  edge true_e = get_true_edge_from_guard_bb (next_e->dest);
+  translate_isl_ast_for_loop (context_loop, node, true_e, type, lb, ub, ip);
   return last_e;
 }