aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@apple.com>2004-02-27 22:33:02 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2004-02-27 14:33:02 -0800
commitdedbabed297d6c854db74162cd43f996a9739aa6 (patch)
tree0e41eda9e1a986139de052fae0ed8a25bc010fd3
parent58adf39ce4ff3aa30ce18ea241e7d677d7bf47ac (diff)
downloadgcc-dedbabed297d6c854db74162cd43f996a9739aa6.zip
gcc-dedbabed297d6c854db74162cd43f996a9739aa6.tar.gz
gcc-dedbabed297d6c854db74162cd43f996a9739aa6.tar.bz2
c-typeck.c (tagged_types_tu_compatible_p): Speedup common case of the type values being in the same order.
* c-typeck.c (tagged_types_tu_compatible_p) <ENUMERAL_TYPE>: Speedup common case of the type values being in the same order. From-SVN: r78585
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-typeck.c21
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4f88a8b..e6a72d0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-27 Andrew Pinski <apinski@apple.com>
+
+ * c-typeck.c (tagged_types_tu_compatible_p) <ENUMERAL_TYPE>:
+ Speedup common case of the type values being in the same order.
+
2004-02-27 Steve Ellcey <sje@cup.hp.com>
* config/ia64/ia64.h (no-inline-float-divide): New option.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index c10d3e0..e44453a 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -701,6 +701,27 @@ tagged_types_tu_compatible_p (tree t1, tree t2, int flags)
{
case ENUMERAL_TYPE:
{
+
+ /* Speed up the case where the type values are in the same order. */
+ tree tv1 = TYPE_VALUES (t1);
+ tree tv2 = TYPE_VALUES (t2);
+
+ if (tv1 == tv2)
+ return 1;
+
+ for (;tv1 && tv2; tv1 = TREE_CHAIN (tv2), tv2 = TREE_CHAIN (tv2))
+ {
+ if (TREE_PURPOSE (tv1) != TREE_PURPOSE (tv1))
+ break;
+ if (simple_cst_equal (TREE_VALUE (tv1), TREE_VALUE (tv2)) != 1)
+ return 0;
+ }
+
+ if (tv1 == NULL_TREE && tv2 == NULL_TREE)
+ return 1;
+ if (tv1 == NULL_TREE || tv2 == NULL_TREE)
+ return 0;
+
if (list_length (TYPE_VALUES (t1)) != list_length (TYPE_VALUES (t2)))
return 0;