temporarily revert last changes
authorJason Merrill <jason@redhat.com>
Sun, 13 Feb 2005 17:10:47 +0000 (12:10 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 13 Feb 2005 17:10:47 +0000 (12:10 -0500)
From-SVN: r94987

gcc/ChangeLog
gcc/fold-const.c
gcc/gimplify.c
gcc/tree.h

index aa96a6a..2c70f99 100644 (file)
@@ -1,5 +1,7 @@
 2005-02-13  Jason Merrill  <jason@redhat.com>
 
+       [reverted temporarily]
+
        PR mudflap/19319
        * gimplify.c (gimplify_modify_expr_rhs) [CALL_EXPR]: Make return
        slot explicit.
index afe3afc..5d6e5c5 100644 (file)
@@ -8973,29 +8973,6 @@ fold (tree expr)
                             build2 (LE_EXPR, type,
                                     TREE_OPERAND (arg0, 0), arg1)));
 
-      /* Convert ABS_EXPR<x> >= 0 to true.  */
-      else if (code == GE_EXPR
-              && tree_expr_nonnegative_p (arg0)
-              && ! TREE_SIDE_EFFECTS (arg0)
-              && (integer_zerop (arg1)
-                  || (! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))
-                       && real_zerop (arg1))))
-       return constant_boolean_node (true, type);
-
-      /* Convert ABS_EXPR<x> < 0 to false.  */
-      else if (code == LT_EXPR
-              && tree_expr_nonnegative_p (arg0)
-              && ! TREE_SIDE_EFFECTS (arg0)
-              && (integer_zerop (arg1) || real_zerop (arg1)))
-       return constant_boolean_node (false, type);
-
-      /* Convert ABS_EXPR<x> == 0 or ABS_EXPR<x> != 0 to x == 0 or x != 0.  */
-      else if ((code == EQ_EXPR || code == NE_EXPR)
-              && TREE_CODE (arg0) == ABS_EXPR
-              && ! TREE_SIDE_EFFECTS (arg0)
-              && (integer_zerop (arg1) || real_zerop (arg1)))
-       return fold (build2 (code, type, TREE_OPERAND (arg0, 0), arg1));
-
       /* If this is an EQ or NE comparison with zero and ARG0 is
         (1 << foo) & bar, convert it to (bar >> foo) & 1.  Both require
         two operations, but the latter can be done in one less insn
@@ -11217,21 +11194,17 @@ build_fold_addr_expr (tree t)
   return build_fold_addr_expr_with_type (t, build_pointer_type (TREE_TYPE (t)));
 }
 
-/* Given a pointer value T, return a simplified version of an indirection
-   through T, or NULL_TREE if no simplification is possible.  */
+/* Builds an expression for an indirection through T, simplifying some
+   cases.  */
 
-static tree
-fold_indirect_ref_1 (tree t)
+tree
+build_fold_indirect_ref (tree t)
 {
   tree type = TREE_TYPE (TREE_TYPE (t));
   tree sub = t;
   tree subtype;
 
   STRIP_NOPS (sub);
-  subtype = TREE_TYPE (sub);
-  if (!POINTER_TYPE_P (subtype))
-    return NULL_TREE;
-
   if (TREE_CODE (sub) == ADDR_EXPR)
     {
       tree op = TREE_OPERAND (sub, 0);
@@ -11246,6 +11219,7 @@ fold_indirect_ref_1 (tree t)
     }
 
   /* *(foo *)fooarrptr => (*fooarrptr)[0] */
+  subtype = TREE_TYPE (sub);
   if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
       && lang_hooks.types_compatible_p (type, TREE_TYPE (TREE_TYPE (subtype))))
     {
@@ -11253,34 +11227,7 @@ fold_indirect_ref_1 (tree t)
       return build4 (ARRAY_REF, type, sub, size_zero_node, NULL_TREE, NULL_TREE);
     }
 
-  return NULL_TREE;
-}
-
-/* Builds an expression for an indirection through T, simplifying some
-   cases.  */
-
-tree
-build_fold_indirect_ref (tree t)
-{
-  tree sub = fold_indirect_ref_1 (t);
-
-  if (sub)
-    return sub;
-  else
-    return build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (t)), t);
-}
-
-/* Given an INDIRECT_REF T, return either T or a simplified version.  */
-
-tree
-fold_indirect_ref (tree t)
-{
-  tree sub = fold_indirect_ref_1 (TREE_OPERAND (t, 0));
-
-  if (sub)
-    return sub;
-  else
-    return t;
+  return build1 (INDIRECT_REF, type, t);
 }
 
 /* Strip non-trapping, non-side-effecting tree nodes from an expression
index ddb72bc..0fd3943 100644 (file)
@@ -1433,15 +1433,8 @@ gimplify_compound_lval (tree *expr_p, tree *pre_p,
   VARRAY_GENERIC_PTR_NOGC_INIT (stack, 10, "stack");
 
   /* We can handle anything that get_inner_reference can deal with.  */
-  for (p = expr_p; ; p = &TREE_OPERAND (*p, 0))
-    {
-      /* Fold INDIRECT_REFs now to turn them into ARRAY_REFs.  */
-      if (TREE_CODE (*p) == INDIRECT_REF)
-       *p = fold_indirect_ref (*p);
-      if (!handled_component_p (*p))
-       break;
-      VARRAY_PUSH_GENERIC_PTR_NOGC (stack, *p);
-    }
+  for (p = expr_p; handled_component_p (*p); p = &TREE_OPERAND (*p, 0))
+    VARRAY_PUSH_GENERIC_PTR_NOGC (stack, *p);
 
   gcc_assert (VARRAY_ACTIVE_SIZE (stack));
 
@@ -2852,10 +2845,16 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p,
             This kind of code arises in C++ when an object is bound
             to a const reference, and if "x" is a TARGET_EXPR we want
             to take advantage of the optimization below.  */
-         tree t = fold_indirect_ref (*from_p);
-         if (t != *from_p)
+         tree pointer;
+
+         pointer = TREE_OPERAND (*from_p, 0);
+         STRIP_NOPS (pointer);
+         if (TREE_CODE (pointer) == ADDR_EXPR
+             && (lang_hooks.types_compatible_p 
+                 (TREE_TYPE (TREE_OPERAND (pointer, 0)),
+                  TREE_TYPE (*from_p))))
            {
-             *from_p = t;
+             *from_p = TREE_OPERAND (pointer, 0); 
              ret = GS_OK;
            }
          else
@@ -2913,55 +2912,6 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p,
          ret = GS_UNHANDLED;
        break;
 
-      case CALL_EXPR:
-       /* For calls that return in memory, give *to_p as the CALL_EXPR's
-          return slot so that we don't generate a temporary.  */
-       if (aggregate_value_p (*from_p, *from_p))
-         {
-           tree init = *from_p;
-           tree fn = TREE_OPERAND (init, 0);
-           tree args = TREE_OPERAND (init, 1);
-           tree rettype = TREE_TYPE (TREE_TYPE (TREE_TYPE (fn)));
-           tree arg = *to_p;
-           tree type;
-
-           /* Only use the original target if *to_p isn't already
-              addressable; if its address escapes, and the called function
-              uses the NRV optimization, a conforming program could see
-              *to_p change before the called function returns.  */
-           bool use_temp = !is_gimple_non_addressable (*to_p);
-           if (use_temp)
-             {
-               arg = create_tmp_var (rettype, "ret");
-               *from_p = arg;
-             }
-
-           type = TREE_TYPE (arg);
-           /* FIXME: Mark the address as not escaping.  */
-           lang_hooks.mark_addressable (arg);
-           arg = build1 (ADDR_EXPR, build_pointer_type (type), arg);
-           /* The return type might have different cv-quals from arg.  */
-           arg = convert (build_pointer_type (rettype), arg);
-           args = tree_cons (NULL_TREE, arg, args);
-           init = build3 (CALL_EXPR, rettype, fn, args, NULL_TREE);
-           CALL_EXPR_HAS_RETURN_SLOT_ADDR (init) = 1;
-           TREE_USED (init) = 1;
-
-           if (use_temp)
-             gimplify_and_add (init, pre_p);
-           else if (want_value)
-             {
-               gimplify_and_add (init, pre_p);
-               *expr_p = *to_p;
-             }
-           else
-             *expr_p = init;
-           ret = GS_OK;
-         }
-       else
-         ret = GS_UNHANDLED;
-       break;
-
       default:
        ret = GS_UNHANDLED;
        break;
@@ -3594,7 +3544,7 @@ gimplify_target_expr (tree *expr_p, tree *pre_p, tree *post_p)
          ret = GS_OK;
           if (TREE_CODE (init) == BIND_EXPR)
            gimplify_bind_expr (&init, temp, pre_p);
-         if (init != temp)
+          if (init != temp)
            {
              init = build (MODIFY_EXPR, void_type_node, temp, init);
              ret = gimplify_expr (&init, pre_p, post_p, is_gimple_stmt,
@@ -3845,13 +3795,9 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
          recalculate_side_effects (*expr_p);
          break;
 
-       case INDIRECT_REF:
-         *expr_p = fold_indirect_ref (*expr_p);
-         if (*expr_p != save_expr)
-           break;
-         /* else fall through.  */
        case ALIGN_INDIRECT_REF:
        case MISALIGNED_INDIRECT_REF:
+       case INDIRECT_REF:
          ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
                               is_gimple_reg, fb_rvalue);
          recalculate_side_effects (*expr_p);
index 62e9bb3..dea3136 100644 (file)
@@ -3546,7 +3546,6 @@ extern tree fold_build_cleanup_point_expr (tree type, tree expr);
 extern tree fold_strip_sign_ops (tree);
 extern tree build_fold_addr_expr_with_type (tree, tree);
 extern tree build_fold_indirect_ref (tree);
-extern tree fold_indirect_ref (tree);
 extern tree constant_boolean_node (int, tree);
 extern tree build_low_bits_mask (tree, unsigned);