aboutsummaryrefslogtreecommitdiff
path: root/gcc/emit-rtl.c
diff options
context:
space:
mode:
authorAndreas Krebbel <krebbel1@de.ibm.com>2004-03-06 01:21:28 +0000
committerUlrich Weigand <uweigand@gcc.gnu.org>2004-03-06 01:21:28 +0000
commit2b3493c8bb8ee8d00e93c55d9cad5b322aa9f76e (patch)
tree357cb8fd1a073e3842ae68057a07998e44bc5205 /gcc/emit-rtl.c
parent1a4a7065a972b721e9a5555dc87cd8d4d4ce755e (diff)
downloadgcc-2b3493c8bb8ee8d00e93c55d9cad5b322aa9f76e.zip
gcc-2b3493c8bb8ee8d00e93c55d9cad5b322aa9f76e.tar.gz
gcc-2b3493c8bb8ee8d00e93c55d9cad5b322aa9f76e.tar.bz2
rtl.h (mem_expr_equal_p): Function prototype added.
2004-03-05 Andreas Krebbel <krebbel1@de.ibm.com> * rtl.h (mem_expr_equal_p): Function prototype added. * cfgcleanup.c (merge_memattrs): New function. (flow_find_cross_jump): Call merge_memattrs for matching insns. * emit-rtl.c (mem_expr_equal_p): New function. 2004-03-05 Andreas Krebbel <krebbel1@de.ibm.com> * gcc.dg/20040305-1.c: New test. From-SVN: r79005
Diffstat (limited to 'gcc/emit-rtl.c')
-rw-r--r--gcc/emit-rtl.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 6872afa..3032b53 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -1434,6 +1434,40 @@ component_ref_for_mem_expr (tree ref)
TREE_OPERAND (ref, 1));
}
+/* Returns 1 if both MEM_EXPR can be considered equal
+ and 0 otherwise. */
+
+int
+mem_expr_equal_p (tree expr1, tree expr2)
+{
+ if (expr1 == expr2)
+ return 1;
+
+ if (! expr1 || ! expr2)
+ return 0;
+
+ if (TREE_CODE (expr1) != TREE_CODE (expr2))
+ return 0;
+
+ if (TREE_CODE (expr1) == COMPONENT_REF)
+ return
+ mem_expr_equal_p (TREE_OPERAND (expr1, 0),
+ TREE_OPERAND (expr2, 0))
+ && mem_expr_equal_p (TREE_OPERAND (expr1, 1), /* field decl */
+ TREE_OPERAND (expr2, 1));
+
+ if (TREE_CODE (expr1) == INDIRECT_REF)
+ return mem_expr_equal_p (TREE_OPERAND (expr1, 0),
+ TREE_OPERAND (expr2, 0));
+
+ /* Decls with different pointers can't be equal. */
+ if (DECL_P (expr1))
+ return 0;
+
+ abort(); /* ARRAY_REFs, ARRAY_RANGE_REFs and BIT_FIELD_REFs should already
+ have been resolved here. */
+}
+
/* Given REF, a MEM, and T, either the type of X or the expression
corresponding to REF, set the memory attributes. OBJECTP is nonzero
if we are making a new object of this type. BITPOS is nonzero if