aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-strength-reduction.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-09-02 08:14:47 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-09-02 08:14:47 +0000
commit0f605e4049160519f72d1824b3307ff8cdfc31dd (patch)
tree84276c05422fcf6ca3e6133801937224cd916742 /gcc/gimple-ssa-strength-reduction.c
parentc746efcab3f7b2b02511f358f2d6ca37f3fcac5f (diff)
downloadgcc-0f605e4049160519f72d1824b3307ff8cdfc31dd.zip
gcc-0f605e4049160519f72d1824b3307ff8cdfc31dd.tar.gz
gcc-0f605e4049160519f72d1824b3307ff8cdfc31dd.tar.bz2
gimple-ssa-strength-reduction.c (valid_mem_ref_cand_p): New function.
* gimple-ssa-strength-reduction.c (valid_mem_ref_cand_p): New function. (replace_ref): Do not replace a chain of only two candidates which are valid memory references. From-SVN: r275297
Diffstat (limited to 'gcc/gimple-ssa-strength-reduction.c')
-rw-r--r--gcc/gimple-ssa-strength-reduction.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index d343da0..de7f360 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -1999,6 +1999,23 @@ replace_ref (tree *expr, slsr_cand_t c)
update_stmt (c->cand_stmt);
}
+/* Return true if CAND_REF candidate C is a valid memory reference. */
+
+static bool
+valid_mem_ref_cand_p (slsr_cand_t c)
+{
+ if (TREE_CODE (TREE_OPERAND (c->stride, 1)) != INTEGER_CST)
+ return false;
+
+ struct mem_address addr
+ = { NULL_TREE, c->base_expr, TREE_OPERAND (c->stride, 0),
+ TREE_OPERAND (c->stride, 1), wide_int_to_tree (sizetype, c->index) };
+
+ return
+ valid_mem_ref_p (TYPE_MODE (c->cand_type), TYPE_ADDR_SPACE (c->cand_type),
+ &addr);
+}
+
/* Replace CAND_REF candidate C, each sibling of candidate C, and each
dependent of candidate C with an equivalent strength-reduced data
reference. */
@@ -2006,6 +2023,16 @@ replace_ref (tree *expr, slsr_cand_t c)
static void
replace_refs (slsr_cand_t c)
{
+ /* Replacing a chain of only 2 candidates which are valid memory references
+ is generally counter-productive because you cannot recoup the additional
+ calculation added in front of them. */
+ if (c->basis == 0
+ && c->dependent
+ && !lookup_cand (c->dependent)->dependent
+ && valid_mem_ref_cand_p (c)
+ && valid_mem_ref_cand_p (lookup_cand (c->dependent)))
+ return;
+
if (dump_file && (dump_flags & TDF_DETAILS))
{
fputs ("Replacing reference: ", dump_file);