]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-dom.c (find_equivalent_equality_comparison): Do not a eliminate type convers...
authorJeff Law <law@redhat.com>
Fri, 1 Jul 2005 19:01:25 +0000 (13:01 -0600)
committerJeff Law <law@gcc.gnu.org>
Fri, 1 Jul 2005 19:01:25 +0000 (13:01 -0600)
        * tree-ssa-dom.c (find_equivalent_equality_comparison): Do not
        a eliminate type conversion which feeds an equality comparison
        if the original type or either operand in the comparison is a
        function pointer.

From-SVN: r101512

gcc/ChangeLog
gcc/tree-ssa-dom.c

index 97463feafc95c86a93fe303e91793bf80c624a1d..a3ec918beb25d1e1ec6fb9b1d1470b7c39cb8357 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-01  Jeff Law  <law@redhat.com>
+
+       * tree-ssa-dom.c (find_equivalent_equality_comparison): Do not
+       a eliminate type conversion which feeds an equality comparison
+       if the original type or either operand in the comparison is a
+       function pointer.
+
 2005-06-30  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR target/22260
index 59d51c0e8a33efa2a81ff3cbc25cf68dff0ab3bd..8518cf1581b53b78049fbce99be7e1bb8bd5b7bb 100644 (file)
@@ -1929,6 +1929,18 @@ find_equivalent_equality_comparison (tree cond)
     {
       tree def_rhs = TREE_OPERAND (def_stmt, 1);
 
+
+      /* If either operand to the comparison is a pointer to
+        a function, then we can not apply this optimization
+        as some targets require function pointers to be
+        canonicalized and in this case this optimization would
+        eliminate a necessary canonicalization.  */
+      if ((POINTER_TYPE_P (TREE_TYPE (op0))
+          && TREE_CODE (TREE_TYPE (TREE_TYPE (op0))) == FUNCTION_TYPE)
+         || (POINTER_TYPE_P (TREE_TYPE (op1))
+             && TREE_CODE (TREE_TYPE (TREE_TYPE (op1))) == FUNCTION_TYPE))
+       return NULL;
+             
       /* Now make sure the RHS of the MODIFY_EXPR is a typecast.  */
       if ((TREE_CODE (def_rhs) == NOP_EXPR
           || TREE_CODE (def_rhs) == CONVERT_EXPR)
@@ -1942,6 +1954,16 @@ find_equivalent_equality_comparison (tree cond)
              > TYPE_PRECISION (TREE_TYPE (def_rhs)))
            return NULL;
 
+         /* If the inner type of the conversion is a pointer to
+            a function, then we can not apply this optimization
+            as some targets require function pointers to be
+            canonicalized.  This optimization would result in
+            canonicalization of the pointer when it was not originally
+            needed/intended.  */
+         if (POINTER_TYPE_P (def_rhs_inner_type)
+             && TREE_CODE (TREE_TYPE (def_rhs_inner_type)) == FUNCTION_TYPE)
+           return NULL;
+
          /* What we want to prove is that if we convert OP1 to
             the type of the object inside the NOP_EXPR that the
             result is still equivalent to SRC.