]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Simplify gimple_assign_load
authorRichard Biener <rguenther@suse.de>
Fri, 16 Dec 2022 12:48:58 +0000 (13:48 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 19 Apr 2023 09:52:07 +0000 (11:52 +0200)
The following simplifies and outlines gimple_assign_load.  In
particular it is not necessary to get at the base of the possibly
loaded expression but just handle the case of a single handled
component wrapping a non-memory operand.

* gimple.h (gimple_assign_load): Outline...
* gimple.cc (gimple_assign_load): ... here.  Avoid
get_base_address and instead just strip the outermost
handled component, treating a remaining handled component
as load.

gcc/gimple.cc
gcc/gimple.h

index 5e4eda417fbd17440f4e7220e99e6400c769b9ba..e0ba42add39dbd8dac343566f1a08a2933127d0c 100644 (file)
@@ -1788,6 +1788,26 @@ gimple_assign_unary_nop_p (gimple *gs)
               == TYPE_MODE (TREE_TYPE (gimple_assign_rhs1 (gs)))));
 }
 
+/* Return true if GS is an assignment that loads from its rhs1.  */
+
+bool
+gimple_assign_load_p (const gimple *gs)
+{
+  tree rhs;
+  if (!gimple_assign_single_p (gs))
+    return false;
+  rhs = gimple_assign_rhs1 (gs);
+  if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
+    return true;
+  if (handled_component_p (rhs))
+    rhs = TREE_OPERAND (rhs, 0);
+  return (handled_component_p (rhs)
+         || DECL_P (rhs)
+         || TREE_CODE (rhs) == MEM_REF
+         || TREE_CODE (rhs) == TARGET_MEM_REF);
+}
+
+
 /* Set BB to be the basic block holding G.  */
 
 void
index 081d18e425aabd123ac8258a9900e3725f12185d..daf55242f682fdc5fb7350f37d7b7bba577802b3 100644 (file)
@@ -1629,6 +1629,7 @@ tree gimple_call_nonnull_arg (gcall *);
 bool gimple_assign_copy_p (gimple *);
 bool gimple_assign_ssa_name_copy_p (gimple *);
 bool gimple_assign_unary_nop_p (gimple *);
+bool gimple_assign_load_p (const gimple *);
 void gimple_set_bb (gimple *, basic_block);
 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
 void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
@@ -2952,23 +2953,6 @@ gimple_store_p (const gimple *gs)
   return lhs && !is_gimple_reg (lhs);
 }
 
-/* Return true if GS is an assignment that loads from its rhs1.  */
-
-inline bool
-gimple_assign_load_p (const gimple *gs)
-{
-  tree rhs;
-  if (!gimple_assign_single_p (gs))
-    return false;
-  rhs = gimple_assign_rhs1 (gs);
-  if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
-    return true;
-  rhs = get_base_address (rhs);
-  return (DECL_P (rhs)
-         || TREE_CODE (rhs) == MEM_REF || TREE_CODE (rhs) == TARGET_MEM_REF);
-}
-
-
 /* Return true if S is a type-cast assignment.  */
 
 inline bool