OSDN Git Service

2010-04-19 Eric B. Weddington <eric.weddington@atmel.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-pre.c
index 35ce4cc..584f606 100644 (file)
@@ -1407,7 +1407,7 @@ get_representative_for (const pre_expr e)
      that we will return.  */
   if (!pretemp || exprtype != TREE_TYPE (pretemp))
     {
-      pretemp = create_tmp_var (exprtype, "pretmp");
+      pretemp = create_tmp_reg (exprtype, "pretmp");
       get_var_ann (pretemp);
     }
 
@@ -2779,22 +2779,37 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref,
          return NULL_TREE;
        if (genop2)
          {
-           op2expr = get_or_alloc_expr_for (genop2);
-           genop2 = find_or_generate_expression (block, op2expr, stmts,
-                                                 domstmt);
-           if (!genop2)
-             return NULL_TREE;
+           /* Drop zero minimum index.  */
+           if (tree_int_cst_equal (genop2, integer_zero_node))
+             genop2 = NULL_TREE;
+           else
+             {
+               op2expr = get_or_alloc_expr_for (genop2);
+               genop2 = find_or_generate_expression (block, op2expr, stmts,
+                                                     domstmt);
+               if (!genop2)
+                 return NULL_TREE;
+             }
          }
        if (genop3)
          {
            tree elmt_type = TREE_TYPE (TREE_TYPE (genop0));
-           genop3 = size_binop (EXACT_DIV_EXPR, genop3,
-                                size_int (TYPE_ALIGN_UNIT (elmt_type)));
-           op3expr = get_or_alloc_expr_for (genop3);
-           genop3 = find_or_generate_expression (block, op3expr, stmts,
-                                                 domstmt);
-           if (!genop3)
-             return NULL_TREE;
+           /* We can't always put a size in units of the element alignment
+              here as the element alignment may be not visible.  See
+              PR43783.  Simply drop the element size for constant
+              sizes.  */
+           if (tree_int_cst_equal (genop3, TYPE_SIZE_UNIT (elmt_type)))
+             genop3 = NULL_TREE;
+           else
+             {
+               genop3 = size_binop (EXACT_DIV_EXPR, genop3,
+                                    size_int (TYPE_ALIGN_UNIT (elmt_type)));
+               op3expr = get_or_alloc_expr_for (genop3);
+               genop3 = find_or_generate_expression (block, op3expr, stmts,
+                                                     domstmt);
+               if (!genop3)
+                 return NULL_TREE;
+             }
          }
        return build4 (currop->opcode, currop->type, genop0, genop1,
                       genop2, genop3);
@@ -3073,17 +3088,13 @@ create_expression_by_pieces (basic_block block, pre_expr expr,
      that we will return.  */
   if (!pretemp || exprtype != TREE_TYPE (pretemp))
     {
-      pretemp = create_tmp_var (exprtype, "pretmp");
+      pretemp = create_tmp_reg (exprtype, "pretmp");
       get_var_ann (pretemp);
     }
 
   temp = pretemp;
   add_referenced_var (temp);
 
-  if (TREE_CODE (exprtype) == COMPLEX_TYPE
-      || TREE_CODE (exprtype) == VECTOR_TYPE)
-    DECL_GIMPLE_REG_P (temp) = 1;
-
   newstmt = gimple_build_assign (temp, folded);
   name = make_ssa_name (temp, newstmt);
   gimple_assign_set_lhs (newstmt, name);
@@ -4341,15 +4352,16 @@ eliminate (void)
   for (i = 0; VEC_iterate (gimple, to_remove, i, stmt); ++i)
     {
       tree lhs = gimple_assign_lhs (stmt);
+      tree rhs = gimple_assign_rhs1 (stmt);
       use_operand_p use_p;
       gimple use_stmt;
 
       /* If there is a single use only, propagate the equivalency
         instead of keeping the copy.  */
       if (TREE_CODE (lhs) == SSA_NAME
+         && TREE_CODE (rhs) == SSA_NAME
          && single_imm_use (lhs, &use_p, &use_stmt)
-         && may_propagate_copy (USE_FROM_PTR (use_p),
-                                gimple_assign_rhs1 (stmt)))
+         && may_propagate_copy (USE_FROM_PTR (use_p), rhs))
        {
          SET_USE (use_p, gimple_assign_rhs1 (stmt));
          update_stmt (use_stmt);