diff options
author | Richard Biener <rguenther@suse.de> | 2018-12-10 14:20:18 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2018-12-10 14:20:18 +0000 |
commit | e5840e758de4bfdfb2a33d2d24eb025345d355f1 (patch) | |
tree | 37e2882cee9d7c6ba42310dab25555cf27b5a339 /gcc/tree-affine.c | |
parent | dee75828b49690e14b12b949d07826774a023cfd (diff) | |
download | gcc-e5840e758de4bfdfb2a33d2d24eb025345d355f1.zip gcc-e5840e758de4bfdfb2a33d2d24eb025345d355f1.tar.gz gcc-e5840e758de4bfdfb2a33d2d24eb025345d355f1.tar.bz2 |
tree-affine.c (tree_to_aff_combination): Remove unreachable MEM_REF case.
2018-12-10 Richard Biener <rguenther@suse.de>
* tree-affine.c (tree_to_aff_combination): Remove unreachable
MEM_REF case.
(aff_combination_expand): Cache on SSA names, not possibly
on conversion trees. Avoid expanding cases we do not handle.
From-SVN: r266956
Diffstat (limited to 'gcc/tree-affine.c')
-rw-r--r-- | gcc/tree-affine.c | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/gcc/tree-affine.c b/gcc/tree-affine.c index 96b479df..c10cdd0 100644 --- a/gcc/tree-affine.c +++ b/gcc/tree-affine.c @@ -350,25 +350,6 @@ tree_to_aff_combination (tree expr, tree type, aff_tree *comb) } return; - case MEM_REF: - if (TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR) - tree_to_aff_combination (TREE_OPERAND (TREE_OPERAND (expr, 0), 0), - type, comb); - else if (integer_zerop (TREE_OPERAND (expr, 1))) - { - aff_combination_elt (comb, type, expr); - return; - } - else - aff_combination_elt (comb, type, - build2 (MEM_REF, TREE_TYPE (expr), - TREE_OPERAND (expr, 0), - build_int_cst - (TREE_TYPE (TREE_OPERAND (expr, 1)), 0))); - tree_to_aff_combination (TREE_OPERAND (expr, 1), sizetype, &tmp); - aff_combination_add (comb, &tmp); - return; - CASE_CONVERT: { tree otype = TREE_TYPE (expr); @@ -721,21 +702,39 @@ aff_combination_expand (aff_tree *comb ATTRIBUTE_UNUSED, if (TREE_CODE_CLASS (code) == tcc_reference) continue; - if (!*cache) - *cache = new hash_map<tree, name_expansion *>; - name_expansion **slot = &(*cache)->get_or_insert (e); - exp = *slot; - + name_expansion **slot = NULL; + if (*cache) + slot = (*cache)->get (name); + exp = slot ? *slot : NULL; if (!exp) { + /* Only bother to handle cases tree_to_aff_combination will. */ + switch (code) + { + case POINTER_PLUS_EXPR: + case PLUS_EXPR: + case MINUS_EXPR: + case MULT_EXPR: + case NEGATE_EXPR: + case BIT_NOT_EXPR: + CASE_CONVERT: + rhs = gimple_assign_rhs_to_tree (def); + break; + case ADDR_EXPR: + case INTEGER_CST: + case POLY_INT_CST: + rhs = gimple_assign_rhs1 (def); + break; + default: + continue; + } + tree_to_aff_combination (rhs, TREE_TYPE (name), ¤t); exp = XNEW (struct name_expansion); exp->in_progress = 1; - *slot = exp; - rhs = gimple_assign_rhs_to_tree (def); - if (e != name) - rhs = fold_convert (type, rhs); - - tree_to_aff_combination_expand (rhs, comb->type, ¤t, cache); + if (!*cache) + *cache = new hash_map<tree, name_expansion *>; + (*cache)->put (name, exp); + aff_combination_expand (¤t, cache); exp->expansion = current; exp->in_progress = 0; } @@ -746,6 +745,8 @@ aff_combination_expand (aff_tree *comb ATTRIBUTE_UNUSED, gcc_assert (!exp->in_progress); current = exp->expansion; } + if (!useless_type_conversion_p (comb->type, current.type)) + aff_combination_convert (¤t, comb->type); /* Accumulate the new terms to TO_ADD, so that we do not modify COMB while traversing it; include the term -coef * E, to remove |