OSDN Git Service

* gcc.dg/asm-b.c: Fix comment typos.
[pf3gnuchains/gcc-fork.git] / gcc / gimplify.c
index d86379c..d461d77 100644 (file)
@@ -1433,8 +1433,15 @@ 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; handled_component_p (*p); p = &TREE_OPERAND (*p, 0))
-    VARRAY_PUSH_GENERIC_PTR_NOGC (stack, *p);
+  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);
+    }
 
   gcc_assert (VARRAY_ACTIVE_SIZE (stack));
 
@@ -1911,7 +1918,7 @@ shortcut_cond_expr (tree expr)
   tree true_label, false_label, end_label, t;
   tree *true_label_p;
   tree *false_label_p;
-  bool emit_end, emit_false;
+  bool emit_end, emit_false, jump_over_else;
   bool then_se = then_ && TREE_SIDE_EFFECTS (then_);
   bool else_se = else_ && TREE_SIDE_EFFECTS (else_);
 
@@ -1923,6 +1930,7 @@ shortcut_cond_expr (tree expr)
        {
          TREE_OPERAND (expr, 0) = TREE_OPERAND (pred, 1);
          then_ = shortcut_cond_expr (expr);
+         then_se = then_ && TREE_SIDE_EFFECTS (then_);
          pred = TREE_OPERAND (pred, 0);
          expr = build (COND_EXPR, void_type_node, pred, then_, NULL_TREE);
        }
@@ -1937,6 +1945,7 @@ shortcut_cond_expr (tree expr)
        {
          TREE_OPERAND (expr, 0) = TREE_OPERAND (pred, 1);
          else_ = shortcut_cond_expr (expr);
+         else_se = else_ && TREE_SIDE_EFFECTS (else_);
          pred = TREE_OPERAND (pred, 0);
          expr = build (COND_EXPR, void_type_node, pred, NULL_TREE, else_);
        }
@@ -2013,6 +2022,16 @@ shortcut_cond_expr (tree expr)
   emit_end = (end_label == NULL_TREE);
   emit_false = (false_label == NULL_TREE);
 
+  /* We only emit the jump over the else clause if we have to--if the
+     then clause may fall through.  Otherwise we can wind up with a
+     useless jump and a useless label at the end of gimplified code,
+     which will cause us to think that this conditional as a whole
+     falls through even if it doesn't.  If we then inline a function
+     which ends with such a condition, that can cause us to issue an
+     inappropriate warning about control reaching the end of a
+     non-void function.  */
+  jump_over_else = block_may_fallthru (then_);
+
   pred = shortcut_cond_r (pred, true_label_p, false_label_p);
 
   expr = NULL;
@@ -2021,8 +2040,11 @@ shortcut_cond_expr (tree expr)
   append_to_statement_list (then_, &expr);
   if (else_se)
     {
-      t = build_and_jump (&end_label);
-      append_to_statement_list (t, &expr);
+      if (jump_over_else)
+       {
+         t = build_and_jump (&end_label);
+         append_to_statement_list (t, &expr);
+       }
       if (emit_false)
        {
          t = build1 (LABEL_EXPR, void_type_node, false_label);
@@ -2586,11 +2608,12 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
 
        categorize_ctor_elements (ctor, &num_nonzero_elements,
                                  &num_nonconstant_elements,
-                                 &num_ctor_elements);
+                                 &num_ctor_elements, &cleared);
 
        /* If a const aggregate variable is being initialized, then it
           should never be a lose to promote the variable to be static.  */
        if (num_nonconstant_elements == 0
+           && num_nonzero_elements > 1
            && TREE_READONLY (object)
            && TREE_CODE (object) == VAR_DECL)
          {
@@ -2672,7 +2695,6 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
        num_type_elements = count_type_elements (TREE_TYPE (ctor));
 
        /* If there are "lots" of zeros, then block clear the object first.  */
-       cleared = false;
        if (num_type_elements - num_nonzero_elements > CLEAR_RATIO
            && num_nonzero_elements < num_type_elements/4)
          cleared = true;
@@ -2761,20 +2783,33 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
     case VECTOR_TYPE:
       /* Go ahead and simplify constant constructors to VECTOR_CST.  */
       if (TREE_CONSTANT (ctor))
-       TREE_OPERAND (*expr_p, 1) = build_vector (type, elt_list);
-      else
        {
-         /* Vector types use CONSTRUCTOR all the way through gimple
-            compilation as a general initializer.  */
-         for (; elt_list; elt_list = TREE_CHAIN (elt_list))
+         tree tem;
+
+         /* Even when ctor is constant, it might contain non-*_CST
+            elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't
+            belong into VECTOR_CST nodes.  */
+         for (tem = elt_list; tem; tem = TREE_CHAIN (tem))
+           if (! CONSTANT_CLASS_P (TREE_VALUE (tem)))
+             break;
+
+         if (! tem)
            {
-             enum gimplify_status tret;
-             tret = gimplify_expr (&TREE_VALUE (elt_list), pre_p, post_p,
-                                   is_gimple_val, fb_rvalue);
-             if (tret == GS_ERROR)
-               ret = GS_ERROR;
+             TREE_OPERAND (*expr_p, 1) = build_vector (type, elt_list);
+             break;
            }
        }
+
+      /* Vector types use CONSTRUCTOR all the way through gimple
+        compilation as a general initializer.  */
+      for (; elt_list; elt_list = TREE_CHAIN (elt_list))
+       {
+         enum gimplify_status tret;
+         tret = gimplify_expr (&TREE_VALUE (elt_list), pre_p, post_p,
+                               is_gimple_val, fb_rvalue);
+         if (tret == GS_ERROR)
+           ret = GS_ERROR;
+       }
       break;
 
     default:
@@ -2817,16 +2852,10 @@ 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 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))))
+         tree t = fold_indirect_ref (*from_p);
+         if (t != *from_p)
            {
-             *from_p = TREE_OPERAND (pointer, 0); 
+             *from_p = t;
              ret = GS_OK;
            }
          else
@@ -3516,7 +3545,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,
@@ -3767,9 +3796,13 @@ 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);
@@ -4217,7 +4250,7 @@ gimplify_type_sizes (tree type, tree *list_p)
   tree field, t;
 
   /* Note that we do not check for TYPE_SIZES_GIMPLIFIED already set because
-     that's not supposed to happen on types where gimplifcation does anything.
+     that's not supposed to happen on types where gimplification does anything.
      We should assert that it isn't set, but we can indeed be called multiple
      times on pointers.  Unfortunately, this includes fat pointers which we
      can't easily test for.  We could pass TYPE down to gimplify_one_sizepos