diff options
author | Richard Biener <rguenther@suse.de> | 2020-03-18 09:13:17 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-03-18 09:14:48 +0100 |
commit | 4e3d3e40726e1b68bf52fa205c68495124ea60b8 (patch) | |
tree | c40b5b145bca1448d3196a5857b9fd30bbd77c8f /gcc/tree-ssa-forwprop.c | |
parent | af8656be8df68ac26840f7844430fd595255ebd2 (diff) | |
download | gcc-4e3d3e40726e1b68bf52fa205c68495124ea60b8.zip gcc-4e3d3e40726e1b68bf52fa205c68495124ea60b8.tar.gz gcc-4e3d3e40726e1b68bf52fa205c68495124ea60b8.tar.bz2 |
middle-end/94188 fix fold of addr expression generation
This adds a missing type conversion to build_fold_addr_expr and adjusts
fallout - build_fold_addr_expr was used as a convenience to build an
ADDR_EXPR but some callers do not expect the result to be simplified
to something else.
2020-03-18 Richard Biener <rguenther@suse.de>
PR middle-end/94188
* fold-const.c (build_fold_addr_expr): Convert address to
correct type.
* asan.c (maybe_create_ssa_name): Strip useless type conversions.
* gimple-fold.c (gimple_fold_stmt_to_constant_1): Use build1
to build the ADDR_EXPR which we don't really want to simplify.
* tree-ssa-dom.c (record_equivalences_from_stmt): Likewise.
* tree-ssa-loop-im.c (gather_mem_refs_stmt): Likewise.
* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Likewise.
(simplify_builtin_call): Strip useless type conversions.
* tree-ssa-strlen.c (new_strinfo): Likewise.
* gcc.dg/pr94188.c: New testcase.
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r-- | gcc/tree-ssa-forwprop.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index f65216d..61b4eec 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "vec-perm-indices.h" #include "internal-fn.h" #include "cgraph.h" +#include "tree-ssa.h" /* This pass propagates the RHS of assignment statements into use sites of the LHS of the assignment. It's basically a specialized @@ -732,16 +733,15 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, if (TREE_CODE (new_def_rhs) == MEM_REF && !is_gimple_mem_ref_addr (TREE_OPERAND (new_def_rhs, 0))) return false; - new_def_rhs = build_fold_addr_expr_with_type (new_def_rhs, - TREE_TYPE (rhs)); + new_def_rhs = build1 (ADDR_EXPR, TREE_TYPE (rhs), new_def_rhs); /* Recurse. If we could propagate into all uses of lhs do not bother to replace into the current use but just pretend we did. */ - if (TREE_CODE (new_def_rhs) == ADDR_EXPR - && forward_propagate_addr_expr (lhs, new_def_rhs, single_use_p)) + if (forward_propagate_addr_expr (lhs, new_def_rhs, single_use_p)) return true; - if (useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (new_def_rhs))) + if (useless_type_conversion_p (TREE_TYPE (lhs), + TREE_TYPE (new_def_rhs))) gimple_assign_set_rhs_with_ops (use_stmt_gsi, TREE_CODE (new_def_rhs), new_def_rhs); else if (is_gimple_min_invariant (new_def_rhs)) @@ -1319,6 +1319,7 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2) || !tree_fits_shwi_p (src1)) break; ptr1 = build_fold_addr_expr (ptr1); + STRIP_USELESS_TYPE_CONVERSION (ptr1); callee1 = NULL_TREE; len1 = size_one_node; lhs1 = NULL_TREE; |