]> gcc.gnu.org Git - gcc.git/commitdiff
ipa/94217 simplify offsetted address build
authorRichard Biener <rguenther@suse.de>
Thu, 19 Mar 2020 09:19:24 +0000 (10:19 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 19 Mar 2020 09:20:30 +0000 (10:20 +0100)
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.

gcc/ChangeLog
gcc/ipa-cp.c

index f015a55a87000043d9ab8dd8dbb746829c05b7f5..c91c73a663947b130e976820c4142a3b96dcf3cb 100644 (file)
@@ -1,3 +1,9 @@
+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
index 27c020b81998823b401d40672c5cc9830abbb490..1c17010e369fab4f51af14478069c41d5c3df696 100644 (file)
@@ -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;
This page took 0.0685 seconds and 5 git commands to generate.