aboutsummaryrefslogtreecommitdiff
path: root/gcc/graphite-isl-ast-to-gimple.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-12-04 14:04:36 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-12-04 14:04:36 +0000
commit86502ecfe41ae0ba0b3698be199797496e77c8c1 (patch)
treeb8153da555cc69903974fcaf8206c072d46b03ba /gcc/graphite-isl-ast-to-gimple.c
parentca4564f9a45ad806087e6cc5df3c6882a1879cdf (diff)
downloadgcc-86502ecfe41ae0ba0b3698be199797496e77c8c1.zip
gcc-86502ecfe41ae0ba0b3698be199797496e77c8c1.tar.gz
gcc-86502ecfe41ae0ba0b3698be199797496e77c8c1.tar.bz2
re PR tree-optimization/83255 ([graphite] Wrong code w/ -O1 -floop-nest-optimize)
2017-12-04 Richard Biener <rguenther@suse.de> PR tree-optimization/83255 * graphite-isl-ast-to-gimple.c (translate_isl_ast_node_for): Re-add zero-iteration check. * gcc.dg/graphite/pr83255.c: New testcase. From-SVN: r255382
Diffstat (limited to 'gcc/graphite-isl-ast-to-gimple.c')
-rw-r--r--gcc/graphite-isl-ast-to-gimple.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index 16570e1..c565cf0 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -720,6 +720,32 @@ translate_isl_ast_node_for (loop_p context_loop, __isl_keep isl_ast_node *node,
ub = integer_zero_node;
edge last_e = single_succ_edge (split_edge (next_e));
+
+ /* Compensate for the fact that we emit a do { } while loop from
+ a for ISL AST.
+ ??? We often miss constraints on niter because the SESE region
+ doesn't cover loop header copies. Ideally we'd add constraints
+ for all relevant dominating conditions. */
+ if (TREE_CODE (lb) == INTEGER_CST && TREE_CODE (ub) == INTEGER_CST
+ && tree_int_cst_compare (lb, ub) <= 0)
+ ;
+ else
+ {
+ tree one = build_one_cst (POINTER_TYPE_P (type) ? sizetype : type);
+ /* Adding +1 and using LT_EXPR helps with loop latches that have a
+ loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this
+ becomes 2^k-1 due to integer overflow, and the condition lb <= ub
+ is true, even if we do not want this. However lb < ub + 1 is false,
+ as expected. */
+ tree ub_one = fold_build2 (POINTER_TYPE_P (type)
+ ? POINTER_PLUS_EXPR : PLUS_EXPR,
+ type, ub, one);
+ create_empty_if_region_on_edge (next_e,
+ fold_build2 (LT_EXPR, boolean_type_node,
+ lb, ub_one));
+ next_e = get_true_edge_from_guard_bb (next_e->dest);
+ }
+
translate_isl_ast_for_loop (context_loop, node, next_e,
type, lb, ub, ip);
return last_e;