public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Use build_fold_addr_expr_with_type(_loc) more often
@ 2022-05-05 12:08 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-05-05 12:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:cebe45279cc2ad13cdcc324b868971c7a3e79495

commit cebe45279cc2ad13cdcc324b868971c7a3e79495
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Mon Apr 11 17:42:52 2022 +0100

    Use build_fold_addr_expr_with_type(_loc) more often
    
    There are already dedicated build_fold_addr_expr_with_type(_loc)
    routines for folding an ADDR_EXPR, but some pieces of code were
    instead using the generic fold_build1(_loc), which don't do much
    folding for ADDR_EXPRs.

Diff:
---
 gcc/builtins.c             | 2 +-
 gcc/fortran/trans-array.c  | 5 +++--
 gcc/fortran/trans.c        | 8 ++++----
 gcc/tree-ssa-loop-ivopts.c | 3 ++-
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 29c96f05e5f..2f2b2414524 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5718,7 +5718,7 @@ stabilize_va_list_loc (location_t loc, tree valist, int needs_lvalue)
 	  if (! TREE_SIDE_EFFECTS (valist))
 	    return valist;
 
-	  valist = fold_build1_loc (loc, ADDR_EXPR, pt, valist);
+	  valist = build_fold_addr_expr_with_type_loc (loc, valist, pt);
 	  TREE_SIDE_EFFECTS (valist) = 1;
 	}
 
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index dcb0d166f9f..96c12a44ff9 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -6414,8 +6414,9 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym,
       tmp = fold_build1_loc (input_location, DECL_EXPR,
 			     TREE_TYPE (space), space);
       gfc_add_expr_to_block (&init, tmp);
-      addr = fold_build1_loc (gfc_get_location (&sym->declared_at),
-			      ADDR_EXPR, TREE_TYPE (decl), space);
+      addr = build_fold_addr_expr_with_type_loc
+	       (gfc_get_location (&sym->declared_at),
+		space, TREE_TYPE (decl));
       gfc_add_modify (&init, decl, addr);
       gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
       tmp = NULL_TREE;
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index ed054261452..997326c6ac4 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -300,7 +300,7 @@ gfc_build_addr_expr (tree type, tree t)
       tree base = get_base_address (t);
       if (base && DECL_P (base))
         TREE_ADDRESSABLE (base) = 1;
-      t = fold_build1_loc (input_location, ADDR_EXPR, natural_type, t);
+      t = build_fold_addr_expr_with_type_loc (input_location, t, natural_type);
     }
 
   if (type && natural_type != type)
@@ -517,9 +517,9 @@ trans_runtime_error_vararg (tree errorfunc, locus* where, const char* msgid,
 
   loc = where ? gfc_get_location (where) : input_location;
   tmp = fold_build_call_array_loc (loc, TREE_TYPE (fntype),
-				   fold_build1_loc (loc, ADDR_EXPR,
-					     build_pointer_type (fntype),
-					     errorfunc),
+				   build_fold_addr_expr_with_type_loc
+				     (loc, errorfunc,
+				      build_pointer_type (fntype)),
 				   nargs + 2, argarray);
   gfc_add_expr_to_block (&block, tmp);
 
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 0148a1fdee7..4e3ef0aaada 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -7518,7 +7518,8 @@ rewrite_use_address (struct ivopts_data *data,
 
   if (use->type == USE_PTR_ADDRESS)
     {
-      ref = fold_build1 (ADDR_EXPR, build_pointer_type (use->mem_type), ref);
+      tree ptr_type = build_pointer_type (use->mem_type);
+      ref = build_fold_addr_expr_with_type (ref, ptr_type);
       ref = fold_convert (get_use_type (use), ref);
       ref = force_gimple_operand_gsi (&bsi, ref, true, NULL_TREE,
 				      true, GSI_SAME_STMT);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-05 12:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:08 [gcc(refs/vendors/ARM/heads/morello)] Use build_fold_addr_expr_with_type(_loc) more often Matthew Malcomson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).