diff options
author | Bin Cheng <bin.cheng@arm.com> | 2017-07-28 14:57:05 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2017-07-28 14:57:05 +0000 |
commit | 3c62a7fb6e7d2a0f2ee20118de2b0f16cc1b2f74 (patch) | |
tree | 8606d60bc15bc697fbb98d04e0af3563350943f7 /gcc/tree-predcom.c | |
parent | aa4de160ccafb70787013aaa540375aaac0056da (diff) | |
download | gcc-3c62a7fb6e7d2a0f2ee20118de2b0f16cc1b2f74.zip gcc-3c62a7fb6e7d2a0f2ee20118de2b0f16cc1b2f74.tar.gz gcc-3c62a7fb6e7d2a0f2ee20118de2b0f16cc1b2f74.tar.bz2 |
tree-predcom.c (ref_at_iteration): Add parameter NITERS.
* tree-predcom.c (ref_at_iteration): Add parameter NITERS. Compute
memory reference to DR at (NITERS + ITERS)-th iteration of loop.
From-SVN: r250667
Diffstat (limited to 'gcc/tree-predcom.c')
-rw-r--r-- | gcc/tree-predcom.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index 089d3c6..8861f31 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -1370,11 +1370,12 @@ replace_ref_with (gimple *stmt, tree new_tree, bool set, bool in_lhs) gsi_insert_after (&bsi, new_stmt, GSI_NEW_STMT); } -/* Returns a memory reference to DR in the ITER-th iteration of - the loop it was analyzed in. Append init stmts to STMTS. */ +/* Returns a memory reference to DR in the (NITERS + ITER)-th iteration + of the loop it was analyzed in. Append init stmts to STMTS. */ static tree -ref_at_iteration (data_reference_p dr, int iter, gimple_seq *stmts) +ref_at_iteration (data_reference_p dr, int iter, + gimple_seq *stmts, tree niters = NULL_TREE) { tree off = DR_OFFSET (dr); tree coff = DR_INIT (dr); @@ -1383,14 +1384,27 @@ ref_at_iteration (data_reference_p dr, int iter, gimple_seq *stmts) tree ref_type = NULL_TREE; tree ref_op1 = NULL_TREE; tree ref_op2 = NULL_TREE; - if (iter == 0) - ; - else if (TREE_CODE (DR_STEP (dr)) == INTEGER_CST) - coff = size_binop (PLUS_EXPR, coff, - size_binop (MULT_EXPR, DR_STEP (dr), ssize_int (iter))); - else - off = size_binop (PLUS_EXPR, off, - size_binop (MULT_EXPR, DR_STEP (dr), ssize_int (iter))); + tree new_offset; + + if (iter != 0) + { + new_offset = size_binop (MULT_EXPR, DR_STEP (dr), ssize_int (iter)); + if (TREE_CODE (new_offset) == INTEGER_CST) + coff = size_binop (PLUS_EXPR, coff, new_offset); + else + off = size_binop (PLUS_EXPR, off, new_offset); + } + + if (niters != NULL_TREE) + { + niters = fold_convert (ssizetype, niters); + new_offset = size_binop (MULT_EXPR, DR_STEP (dr), niters); + if (TREE_CODE (niters) == INTEGER_CST) + coff = size_binop (PLUS_EXPR, coff, new_offset); + else + off = size_binop (PLUS_EXPR, off, new_offset); + } + /* While data-ref analysis punts on bit offsets it still handles bitfield accesses at byte boundaries. Cope with that. Note that if the bitfield object also starts at a byte-boundary we can simply |