diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-01-16 17:05:27 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-01-16 17:05:27 +0100 |
commit | 8c01de7fb34ae3d5fbedc3377cf431aa34ebca64 (patch) | |
tree | 65bbd29ce62f63c8255d1398996d1bb5aadc998f /gcc/fortran | |
parent | cb9cf03b1dee7d180025763533904fe1c71907f4 (diff) | |
download | gcc-8c01de7fb34ae3d5fbedc3377cf431aa34ebca64.zip gcc-8c01de7fb34ae3d5fbedc3377cf431aa34ebca64.tar.gz gcc-8c01de7fb34ae3d5fbedc3377cf431aa34ebca64.tar.bz2 |
re PR fortran/52865 (GCC can't vectorize fortran loop but able to vectorize similar c-loop)
PR fortran/52865
* trans-stmt.c (gfc_trans_do): Put countm1-- before conditional
and use value of countm1 before the decrement in the condition.
From-SVN: r195241
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-stmt.c | 21 |
2 files changed, 19 insertions, 8 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f297deb..c7f2001 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2013-01-16 Jakub Jelinek <jakub@redhat.com> + + PR fortran/52865 + * trans-stmt.c (gfc_trans_do): Put countm1-- before conditional + and use value of countm1 before the decrement in the condition. + 2013-01-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/54286 diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 3aabd28..1d240cb 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -1518,8 +1518,9 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar, body; cycle_label: dovar += step - if (countm1 ==0) goto exit_label; + countm1t = countm1; countm1--; + if (countm1t == 0) goto exit_label; } exit_label: @@ -1739,19 +1740,23 @@ gfc_trans_do (gfc_code * code, tree exit_cond) if (gfc_option.rtcheck & GFC_RTCHECK_DO) gfc_add_modify_loc (loc, &body, saved_dovar, dovar); - /* End with the loop condition. Loop until countm1 == 0. */ - cond = fold_build2_loc (loc, EQ_EXPR, boolean_type_node, countm1, - build_int_cst (utype, 0)); - tmp = fold_build1_loc (loc, GOTO_EXPR, void_type_node, exit_label); - tmp = fold_build3_loc (loc, COND_EXPR, void_type_node, - cond, tmp, build_empty_stmt (loc)); - gfc_add_expr_to_block (&body, tmp); + /* Initialize countm1t. */ + tree countm1t = gfc_create_var (utype, "countm1t"); + gfc_add_modify_loc (loc, &body, countm1t, countm1); /* Decrement the loop count. */ tmp = fold_build2_loc (loc, MINUS_EXPR, utype, countm1, build_int_cst (utype, 1)); gfc_add_modify_loc (loc, &body, countm1, tmp); + /* End with the loop condition. Loop until countm1t == 0. */ + cond = fold_build2_loc (loc, EQ_EXPR, boolean_type_node, countm1t, + build_int_cst (utype, 0)); + tmp = fold_build1_loc (loc, GOTO_EXPR, void_type_node, exit_label); + tmp = fold_build3_loc (loc, COND_EXPR, void_type_node, + cond, tmp, build_empty_stmt (loc)); + gfc_add_expr_to_block (&body, tmp); + /* End of loop body. */ tmp = gfc_finish_block (&body); |