GCC with patches for OS216
Revision | 8ca74c42ca51abb08f66d1c6f26fcf00d2b829fc (tree) |
---|---|
Zeit | 2017-12-05 22:40:08 |
Autor | Bin Cheng <amker@gcc....> |
Commiter | Bin Cheng |
gimple-loop-interchange.cc (struct induction): Rename fields.
2017-12-05 Bin Cheng <bin.cheng@arm.com>
* gimple-loop-interchange.cc (struct induction): Rename fields.
(dump_induction, loop_cand::analyze_induction_var): Update uses.
(loop_cand::undo_simple_reduction): Ditto.
(tree_loop_interchange::map_inductions_to_loop): Ditto.
(tree_loop_interchange::can_interchange_loops): Delete.
(tree_loop_interchange::interchange): Inline can_interchange_loops.
From-SVN: r255419
@@ -98,10 +98,11 @@ typedef struct induction | ||
98 | 98 | { |
99 | 99 | /* IV itself. */ |
100 | 100 | tree var; |
101 | - /* Initializer. */ | |
102 | - tree init; | |
103 | - /* IV's base and step part of SCEV. */ | |
104 | - tree base; | |
101 | + /* IV's initializing value, which is the init arg of the IV PHI node. */ | |
102 | + tree init_val; | |
103 | + /* IV's initializing expr, which is (the expanded result of) init_val. */ | |
104 | + tree init_expr; | |
105 | + /* IV's step. */ | |
105 | 106 | tree step; |
106 | 107 | } *induction_p; |
107 | 108 |
@@ -159,7 +160,7 @@ dump_induction (struct loop *loop, induction_p iv) | ||
159 | 160 | fprintf (dump_file, " Induction: "); |
160 | 161 | print_generic_expr (dump_file, iv->var, TDF_SLIM); |
161 | 162 | fprintf (dump_file, " = {"); |
162 | - print_generic_expr (dump_file, iv->base, TDF_SLIM); | |
163 | + print_generic_expr (dump_file, iv->init_expr, TDF_SLIM); | |
163 | 164 | fprintf (dump_file, ", "); |
164 | 165 | print_generic_expr (dump_file, iv->step, TDF_SLIM); |
165 | 166 | fprintf (dump_file, "}_%d\n", loop->num); |
@@ -700,8 +701,8 @@ loop_cand::analyze_induction_var (tree var, tree chrec) | ||
700 | 701 | { |
701 | 702 | struct induction *iv = XCNEW (struct induction); |
702 | 703 | iv->var = var; |
703 | - iv->init = init; | |
704 | - iv->base = chrec; | |
704 | + iv->init_val = init; | |
705 | + iv->init_expr = chrec; | |
705 | 706 | iv->step = build_int_cst (TREE_TYPE (chrec), 0); |
706 | 707 | m_inductions.safe_push (iv); |
707 | 708 | return true; |
@@ -715,8 +716,8 @@ loop_cand::analyze_induction_var (tree var, tree chrec) | ||
715 | 716 | |
716 | 717 | struct induction *iv = XCNEW (struct induction); |
717 | 718 | iv->var = var; |
718 | - iv->init = init; | |
719 | - iv->base = CHREC_LEFT (chrec); | |
719 | + iv->init_val = init; | |
720 | + iv->init_expr = CHREC_LEFT (chrec); | |
720 | 721 | iv->step = CHREC_RIGHT (chrec); |
721 | 722 | |
722 | 723 | if (dump_file && (dump_flags & TDF_DETAILS)) |
@@ -894,14 +895,14 @@ loop_cand::undo_simple_reduction (reduction_p re, bitmap dce_seeds) | ||
894 | 895 | /* Find all stmts on which expression "MEM_REF[idx]" depends. */ |
895 | 896 | find_deps_in_bb_for_stmt (&stmts, gimple_bb (re->consumer), re->consumer); |
896 | 897 | /* Because we generate new stmt loading from the MEM_REF to TMP. */ |
897 | - tree tmp = copy_ssa_name (re->var); | |
898 | + tree cond, tmp = copy_ssa_name (re->var); | |
898 | 899 | stmt = gimple_build_assign (tmp, re->init_ref); |
899 | 900 | gimple_seq_add_stmt_without_update (&stmts, stmt); |
900 | 901 | |
901 | 902 | /* Init new_var to MEM_REF or CONST depending on if it is the first |
902 | 903 | iteration. */ |
903 | 904 | induction_p iv = m_inductions[0]; |
904 | - tree cond = fold_build2 (NE_EXPR, boolean_type_node, iv->var, iv->init); | |
905 | + cond = fold_build2 (NE_EXPR, boolean_type_node, iv->var, iv->init_val); | |
905 | 906 | new_var = copy_ssa_name (re->var); |
906 | 907 | stmt = gimple_build_assign (new_var, COND_EXPR, cond, tmp, re->init); |
907 | 908 | gimple_seq_add_stmt_without_update (&stmts, stmt); |
@@ -964,7 +965,6 @@ public: | ||
964 | 965 | private: |
965 | 966 | void update_data_info (unsigned, unsigned, vec<data_reference_p>, vec<ddr_p>); |
966 | 967 | bool valid_data_dependences (unsigned, unsigned, vec<ddr_p>); |
967 | - bool can_interchange_loops (loop_cand &, loop_cand &); | |
968 | 968 | void interchange_loops (loop_cand &, loop_cand &); |
969 | 969 | void map_inductions_to_loop (loop_cand &, loop_cand &); |
970 | 970 | void move_code_to_inner_loop (struct loop *, struct loop *, basic_block *); |
@@ -1056,21 +1056,6 @@ tree_loop_interchange::valid_data_dependences (unsigned i_idx, unsigned o_idx, | ||
1056 | 1056 | return true; |
1057 | 1057 | } |
1058 | 1058 | |
1059 | -/* Return true if ILOOP and OLOOP can be interchanged in terms of code | |
1060 | - transformation. */ | |
1061 | - | |
1062 | -bool | |
1063 | -tree_loop_interchange::can_interchange_loops (loop_cand &iloop, | |
1064 | - loop_cand &oloop) | |
1065 | -{ | |
1066 | - return (iloop.analyze_carried_vars (NULL) | |
1067 | - && iloop.analyze_lcssa_phis () | |
1068 | - && oloop.analyze_carried_vars (&iloop) | |
1069 | - && oloop.analyze_lcssa_phis () | |
1070 | - && iloop.can_interchange_p (NULL) | |
1071 | - && oloop.can_interchange_p (&iloop)); | |
1072 | -} | |
1073 | - | |
1074 | 1059 | /* Interchange two loops specified by ILOOP and OLOOP. */ |
1075 | 1060 | |
1076 | 1061 | void |
@@ -1193,7 +1178,8 @@ tree_loop_interchange::map_inductions_to_loop (loop_cand &src, loop_cand &tgt) | ||
1193 | 1178 | { |
1194 | 1179 | /* Map the IV by creating the same one in target loop. */ |
1195 | 1180 | tree var_before, var_after; |
1196 | - tree base = unshare_expr (iv->base), step = unshare_expr (iv->step); | |
1181 | + tree base = unshare_expr (iv->init_expr); | |
1182 | + tree step = unshare_expr (iv->step); | |
1197 | 1183 | create_iv (base, step, SSA_NAME_VAR (iv->var), |
1198 | 1184 | tgt.m_loop, &incr_pos, false, &var_before, &var_after); |
1199 | 1185 | bitmap_set_bit (m_dce_seeds, SSA_NAME_VERSION (var_before)); |
@@ -1580,7 +1566,12 @@ tree_loop_interchange::interchange (vec<data_reference_p> datarefs, | ||
1580 | 1566 | loop_cand oloop (m_loop_nest[o_idx], m_loop_nest[o_idx]); |
1581 | 1567 | |
1582 | 1568 | /* Check if we can do transformation for loop interchange. */ |
1583 | - if (!can_interchange_loops (iloop, oloop)) | |
1569 | + if (!iloop.analyze_carried_vars (NULL) | |
1570 | + || !iloop.analyze_lcssa_phis () | |
1571 | + || !oloop.analyze_carried_vars (&iloop) | |
1572 | + || !oloop.analyze_lcssa_phis () | |
1573 | + || !iloop.can_interchange_p (NULL) | |
1574 | + || !oloop.can_interchange_p (&iloop)) | |
1584 | 1575 | break; |
1585 | 1576 | |
1586 | 1577 | /* Check profitability for loop interchange. */ |