From 7fd1a7474a04fdf68e3b1645de16bcfa45a915d0 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 21 Apr 2017 08:12:27 +0000 Subject: [PATCH] tree-ssa-loop-ivcanon.c (constant_after_peeling): Do not require sth as strict as a simple_iv but a chrec without symbols and an... 2016-04-21 Richard Biener * tree-ssa-loop-ivcanon.c (constant_after_peeling): Do not require sth as strict as a simple_iv but a chrec without symbols and an operand defined in the loop we are peeling (and not some subloop). (propagate_constants_for_unrolling): Propagate all constants. * gcc.dg/vect/no-scevccp-outer-13.c: Adjust to prevent unrolling of inner loops. * gcc.dg/vect/no-scevccp-outer-7.c: Likewise. * gcc.dg/vect/vect-104.c: Likewise. From-SVN: r247048 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.dg/vect/no-scevccp-outer-13.c | 1 + gcc/testsuite/gcc.dg/vect/no-scevccp-outer-7.c | 1 + gcc/testsuite/gcc.dg/vect/vect-104.c | 1 + gcc/tree-ssa-loop-ivcanon.c | 16 +++++++--------- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a94fe68ddc..d2bd25abd15 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-04-21 Richard Biener + + * tree-ssa-loop-ivcanon.c (constant_after_peeling): Do not require + sth as strict as a simple_iv but a chrec without symbols and an + operand defined in the loop we are peeling (and not some subloop). + (propagate_constants_for_unrolling): Propagate all constants. + 2017-04-20 Uros Bizjak PR target/79804 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 22176e677b6..ffb00ec4799 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2016-04-21 Richard Biener + + * gcc.dg/vect/no-scevccp-outer-13.c: Adjust to prevent unrolling + of inner loops. + * gcc.dg/vect/no-scevccp-outer-7.c: Likewise. + * gcc.dg/vect/vect-104.c: Likewise. + 2017-04-21 Eric Botcazou PR tree-optimization/80426 diff --git a/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-13.c b/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-13.c index 04166494fbc..c5e373f8210 100644 --- a/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-13.c +++ b/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-13.c @@ -1,4 +1,5 @@ /* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param max-completely-peel-times=1" } */ #include #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-7.c b/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-7.c index 906b450dcbb..224148d2b1e 100644 --- a/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-7.c +++ b/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-7.c @@ -1,4 +1,5 @@ /* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param max-completely-peel-times=1" } */ #include #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-104.c b/gcc/testsuite/gcc.dg/vect/vect-104.c index 9667b55566c..c7478382915 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-104.c +++ b/gcc/testsuite/gcc.dg/vect/vect-104.c @@ -1,4 +1,5 @@ /* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param max-completely-peel-times=1" } */ #include #include diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 0c3b0d2a407..31dc616c0cc 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -157,8 +157,6 @@ struct loop_size static bool constant_after_peeling (tree op, gimple *stmt, struct loop *loop) { - affine_iv iv; - if (is_gimple_min_invariant (op)) return true; @@ -188,12 +186,12 @@ constant_after_peeling (tree op, gimple *stmt, struct loop *loop) return false; } - /* Induction variables are constants. */ - if (!simple_iv (loop, loop_containing_stmt (stmt), op, &iv, false)) - return false; - if (!is_gimple_min_invariant (iv.base)) + /* Induction variables are constants when defined in loop. */ + if (loop_containing_stmt (stmt) != loop) return false; - if (!is_gimple_min_invariant (iv.step)) + tree ev = analyze_scalar_evolution (loop, op); + if (chrec_contains_undetermined (ev) + || chrec_contains_symbols (ev)) return false; return true; } @@ -1259,7 +1257,7 @@ propagate_constants_for_unrolling (basic_block bb) if (! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (result) && gimple_phi_num_args (phi) == 1 - && TREE_CODE (arg) == INTEGER_CST) + && CONSTANT_CLASS_P (arg)) { replace_uses_by (result, arg); gsi_remove (&gsi, true); @@ -1276,7 +1274,7 @@ propagate_constants_for_unrolling (basic_block bb) tree lhs; if (is_gimple_assign (stmt) - && gimple_assign_rhs_code (stmt) == INTEGER_CST + && TREE_CODE_CLASS (gimple_assign_rhs_code (stmt)) == tcc_constant && (lhs = gimple_assign_lhs (stmt), TREE_CODE (lhs) == SSA_NAME) && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)) { -- 2.30.2