diff options
author | Richard Biener <rguenther@suse.de> | 2020-03-19 10:19:24 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-03-19 10:20:30 +0100 |
commit | f3280e4c0c98e103603bafc466ea49651fe0b7f2 (patch) | |
tree | e0c03a62ca11b9ccaa09f7f8daa3e81005039b36 | |
parent | 73bc09fa8c6b973a928a599498caa66a25c8bc8d (diff) | |
download | gcc-f3280e4c0c98e103603bafc466ea49651fe0b7f2.zip gcc-f3280e4c0c98e103603bafc466ea49651fe0b7f2.tar.gz gcc-f3280e4c0c98e103603bafc466ea49651fe0b7f2.tar.bz2 |
ipa/94217 simplify offsetted address build
This avoids using build_ref_for_offset and build_fold_addr_expr
where type mixup easily results in something not IP invariant.
2020-03-19 Richard Biener <rguenther@suse.de>
PR ipa/94217
* ipa-cp.c (ipa_get_jf_ancestor_result): Avoid build_fold_addr_expr
and build_ref_for_offset.
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ipa-cp.c | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f015a55..c91c73a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2020-03-19 Richard Biener <rguenther@suse.de> + PR ipa/94217 + * ipa-cp.c (ipa_get_jf_ancestor_result): Avoid build_fold_addr_expr + and build_ref_for_offset. + +2020-03-19 Richard Biener <rguenther@suse.de> + PR middle-end/94216 * fold-const.c (fold_binary_loc): Avoid using build_fold_addr_expr when we really want an ADDR_EXPR. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 27c020b..1c17010 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1352,11 +1352,13 @@ ipa_get_jf_ancestor_result (struct ipa_jump_func *jfunc, tree input) gcc_checking_assert (TREE_CODE (input) != TREE_BINFO); if (TREE_CODE (input) == ADDR_EXPR) { - tree t = TREE_OPERAND (input, 0); - t = build_ref_for_offset (EXPR_LOCATION (t), t, - ipa_get_jf_ancestor_offset (jfunc), false, - ptr_type_node, NULL, false); - return build_fold_addr_expr (t); + gcc_checking_assert (is_gimple_ip_invariant_address (input)); + poly_int64 off = ipa_get_jf_ancestor_offset (jfunc); + if (known_eq (off, 0)) + return input; + return build1 (ADDR_EXPR, TREE_TYPE (input), + fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (input)), + input, build_int_cst (ptr_type_node, off))); } else return NULL_TREE; |