]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/24437 (OBJ_TYPE_REF handling in fold_stmt should be moved to fold)
authorAndrew Pinski <pinskia@physics.uc.edu>
Mon, 23 Jan 2006 14:56:45 +0000 (14:56 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Mon, 23 Jan 2006 14:56:45 +0000 (06:56 -0800)
2006-01-23  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24437
        * tree-ssa-ccp.c (fold_stmt): Move folding of OBJ_TYPE_REF
        with a call expr to ...
        * fold-const.c (fold_ternary) <case CALL_EXPR>: Here.

From-SVN: r110116

gcc/ChangeLog
gcc/fold-const.c
gcc/tree-ssa-ccp.c

index b040223024ec8814bbd7da4e6abb522ca55a0915..6ff4fc81868b8cf190db7d761b5697cf46a733f3 100644 (file)
@@ -1,3 +1,10 @@
+2006-01-23  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/24437
+       * tree-ssa-ccp.c (fold_stmt): Move folding of OBJ_TYPE_REF
+       with a call expr to ...
+       * fold-const.c (fold_ternary) <case CALL_EXPR>: Here.
+
 2006-01-23  Richard Guenther  <rguenther@suse.de>
 
        * cfgloopmanip.c (lv_adjust_loop_entry_edge): Add comment
index 2b71ef315eb149e8c7e76d6e4f970d81148f43b3..ed100cefcb8d7767841f2b5e4a6ddc5ca47c5dfd 100644 (file)
@@ -10295,6 +10295,26 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2)
          && TREE_CODE (TREE_OPERAND (op0, 0)) == FUNCTION_DECL
          && DECL_BUILT_IN (TREE_OPERAND (op0, 0)))
        return fold_builtin (TREE_OPERAND (op0, 0), op1, false);
+      /* Check for resolvable OBJ_TYPE_REF.  The only sorts we can resolve
+         here are when we've propagated the address of a decl into the
+         object slot.  */
+      if (TREE_CODE (op0) == OBJ_TYPE_REF
+         && lang_hooks.fold_obj_type_ref
+         && TREE_CODE (OBJ_TYPE_REF_OBJECT (op0)) == ADDR_EXPR
+         && DECL_P (TREE_OPERAND (OBJ_TYPE_REF_OBJECT (op0), 0)))
+       {
+         tree t;
+
+         /* ??? Caution: Broken ADDR_EXPR semantics means that
+             looking at the type of the operand of the addr_expr
+             can yield an array type.  See silly exception in
+             check_pointer_types_r.  */
+
+         t = TREE_TYPE (TREE_TYPE (OBJ_TYPE_REF_OBJECT (op0)));
+         t = lang_hooks.fold_obj_type_ref (op0, t);
+         if (t)
+          return fold_build3 (code, type, t, op1, op2);
+       }
       return NULL_TREE;
 
     case BIT_FIELD_REF:
index 673104556905054712dd1771c5727597ef7be83c..4513f977cd0ff1de8d14ff972d136ecdc74c89d5 100644 (file)
@@ -2342,38 +2342,6 @@ fold_stmt (tree *stmt_p)
       callee = get_callee_fndecl (rhs);
       if (callee && DECL_BUILT_IN (callee))
        result = ccp_fold_builtin (stmt, rhs);
-      else
-       {
-         /* Check for resolvable OBJ_TYPE_REF.  The only sorts we can resolve
-            here are when we've propagated the address of a decl into the
-            object slot.  */
-         /* ??? Should perhaps do this in fold proper.  However, doing it
-            there requires that we create a new CALL_EXPR, and that requires
-            copying EH region info to the new node.  Easier to just do it
-            here where we can just smash the call operand.  */
-         callee = TREE_OPERAND (rhs, 0);
-         if (TREE_CODE (callee) == OBJ_TYPE_REF
-             && lang_hooks.fold_obj_type_ref
-             && TREE_CODE (OBJ_TYPE_REF_OBJECT (callee)) == ADDR_EXPR
-             && DECL_P (TREE_OPERAND
-                        (OBJ_TYPE_REF_OBJECT (callee), 0)))
-           {
-             tree t;
-
-             /* ??? Caution: Broken ADDR_EXPR semantics means that
-                looking at the type of the operand of the addr_expr
-                can yield an array type.  See silly exception in
-                check_pointer_types_r.  */
-
-             t = TREE_TYPE (TREE_TYPE (OBJ_TYPE_REF_OBJECT (callee)));
-             t = lang_hooks.fold_obj_type_ref (callee, t);
-             if (t)
-               {
-                 TREE_OPERAND (rhs, 0) = t;
-                 changed = true;
-               }
-           }
-       }
     }
 
   /* If we couldn't fold the RHS, hand over to the generic fold routines.  */