OSDN Git Service

revert another accidental check-in
[pf3gnuchains/gcc-fork.git] / gcc / tree-complex.c
index 71ebeac..8d680df 100644 (file)
@@ -5,7 +5,7 @@ This file is part of GCC.
    
 GCC is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
+Free Software Foundation; either version 3, or (at your option) any
 later version.
    
 GCC is distributed in the hope that it will be useful, but WITHOUT
@@ -14,9 +14,8 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
    
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
@@ -97,6 +96,8 @@ some_nonzerop (tree t)
 
   if (TREE_CODE (t) == REAL_CST)
     zerop = REAL_VALUES_IDENTICAL (TREE_REAL_CST (t), dconst0);
+  else if (TREE_CODE (t) == FIXED_CST)
+    zerop = fixed_zerop (t);
   else if (TREE_CODE (t) == INTEGER_CST)
     zerop = integer_zerop (t);
 
@@ -160,15 +161,14 @@ is_complex_reg (tree lhs)
 static void
 init_parameter_lattice_values (void)
 {
-  tree parm;
+  tree parm, ssa_name;
 
   for (parm = DECL_ARGUMENTS (cfun->decl); parm ; parm = TREE_CHAIN (parm))
-    if (is_complex_reg (parm) && var_ann (parm) != NULL)
-      {
-       tree ssa_name = gimple_default_def (cfun, parm);
-       VEC_replace (complex_lattice_t, complex_lattice_values,
-                    SSA_NAME_VERSION (ssa_name), VARYING);
-      }
+    if (is_complex_reg (parm)
+       && var_ann (parm) != NULL
+       && (ssa_name = gimple_default_def (cfun, parm)) != NULL_TREE)
+      VEC_replace (complex_lattice_t, complex_lattice_values,
+                  SSA_NAME_VERSION (ssa_name), VARYING);
 }
 
 /* Initialize DONT_SIMULATE_AGAIN for each stmt and phi.  Return false if
@@ -245,6 +245,17 @@ init_dont_simulate_again (void)
                  saw_a_complex_op = true;
                break;
 
+             case REALPART_EXPR:
+             case IMAGPART_EXPR:
+               /* The total store transformation performed during
+                  gimplification creates such uninitialized loads
+                  and we need to lower the statement to be able
+                  to fix things up.  */
+               if (TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME
+                   && ssa_undefined_value_p (TREE_OPERAND (rhs, 0)))
+                 saw_a_complex_op = true;
+               break;
+
              default:
                break;
              }
@@ -751,7 +762,8 @@ expand_complex_move (block_stmt_iterator *bsi, tree stmt, tree type,
          i = build1 (IMAGPART_EXPR, inner_type, lhs);
          update_complex_components_on_edge (e, lhs, r, i);
        }
-      else if (TREE_CODE (rhs) == CALL_EXPR || TREE_SIDE_EFFECTS (rhs))
+      else if (TREE_CODE (rhs) == CALL_EXPR || TREE_SIDE_EFFECTS (rhs)
+              || TREE_CODE (rhs) == PAREN_EXPR)
        {
          r = build1 (REALPART_EXPR, inner_type, lhs);
          i = build1 (IMAGPART_EXPR, inner_type, lhs);
@@ -1035,22 +1047,30 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type,
                         tree ar, tree ai, tree br, tree bi,
                         enum tree_code code)
 {
-  tree rr, ri, ratio, div, t1, t2, tr, ti, cond;
+  tree rr, ri, ratio, div, t1, t2, tr, ti, compare;
   basic_block bb_cond, bb_true, bb_false, bb_join;
 
   /* Examine |br| < |bi|, and branch.  */
   t1 = gimplify_build1 (bsi, ABS_EXPR, inner_type, br);
   t2 = gimplify_build1 (bsi, ABS_EXPR, inner_type, bi);
-  cond = fold_build2 (LT_EXPR, boolean_type_node, t1, t2);
-  STRIP_NOPS (cond);
+  compare = fold_build2 (LT_EXPR, boolean_type_node, t1, t2);
+  STRIP_NOPS (compare);
 
   bb_cond = bb_true = bb_false = bb_join = NULL;
   rr = ri = tr = ti = NULL;
-  if (!TREE_CONSTANT (cond))
+  if (!TREE_CONSTANT (compare))
     {
       edge e;
+      tree cond, tmp;
+
+      tmp = create_tmp_var (boolean_type_node, NULL);
+      cond = build_gimple_modify_stmt (tmp, compare);
+      if (gimple_in_ssa_p (cfun))
+       tmp = make_ssa_name (tmp,  cond);
+      GIMPLE_STMT_OPERAND (cond, 0) = tmp;
+      bsi_insert_before (bsi, cond, BSI_SAME_STMT);
 
-      cond = build3 (COND_EXPR, void_type_node, cond, NULL_TREE, NULL_TREE);
+      cond = build3 (COND_EXPR, void_type_node, tmp, NULL_TREE, NULL_TREE);
       bsi_insert_before (bsi, cond, BSI_SAME_STMT);
 
       /* Split the original block, and create the TRUE and FALSE blocks.  */
@@ -1086,7 +1106,7 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type,
       ti = (ai * ratio) - ar;
       tr = tr / div;
       ti = ti / div;  */
-  if (bb_true || integer_nonzerop (cond))
+  if (bb_true || integer_nonzerop (compare))
     {
       if (bb_true)
        {
@@ -1125,7 +1145,7 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type,
       ti = b - (a * ratio);
       tr = tr / div;
       ti = ti / div;  */
-  if (bb_false || integer_zerop (cond))
+  if (bb_false || integer_zerop (compare))
     {
       if (bb_false)
        {
@@ -1522,8 +1542,10 @@ tree_lower_complex (void)
   return 0;
 }
 
-struct tree_opt_pass pass_lower_complex = 
+struct gimple_opt_pass pass_lower_complex = 
 {
+ {
+  GIMPLE_PASS,
   "cplxlower",                         /* name */
   0,                                   /* gate */
   tree_lower_complex,                  /* execute */
@@ -1538,8 +1560,8 @@ struct tree_opt_pass pass_lower_complex =
   TODO_dump_func
     | TODO_ggc_collect
     | TODO_update_ssa
-    | TODO_verify_stmts,               /* todo_flags_finish */
-  0                                    /* letter */
+    | TODO_verify_stmts                        /* todo_flags_finish */
+ }
 };
 
 \f
@@ -1570,8 +1592,10 @@ gate_no_optimization (void)
   return optimize == 0 || sorrycount || errorcount;
 }
 
-struct tree_opt_pass pass_lower_complex_O0 = 
+struct gimple_opt_pass pass_lower_complex_O0 = 
 {
+ {
+  GIMPLE_PASS,
   "cplxlower0",                                /* name */
   gate_no_optimization,                        /* gate */
   tree_lower_complex_O0,               /* execute */
@@ -1585,5 +1609,5 @@ struct tree_opt_pass pass_lower_complex_O0 =
   0,                                   /* todo_flags_start */
   TODO_dump_func | TODO_ggc_collect
     | TODO_verify_stmts,               /* todo_flags_finish */
-  0                                    /* letter */
+ }
 };