tree-ssa-pre.c (fully_constant_expression): Add fold_convert calls.
authorDaniel Berlin <dberlin@dberlin.org>
Mon, 14 Jul 2008 04:17:55 +0000 (04:17 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Mon, 14 Jul 2008 04:17:55 +0000 (04:17 +0000)
2008-07-13  Daniel Berlin  <dberlin@dberlin.org>

* tree-ssa-pre.c (fully_constant_expression): Add fold_convert
calls.
(create_expression_by_pieces): Fix typo.
(do_regular_insertion): Use debug counter here too.

From-SVN: r137774

gcc/ChangeLog
gcc/tree-ssa-pre.c

index aab33070fc2b330da4e39afba5bc0628e94b7156..39ebddf6420f8d206a5424ec0f2b9e8687451bed 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-13  Daniel Berlin  <dberlin@dberlin.org>
+
+       * tree-ssa-pre.c (fully_constant_expression): Add fold_convert
+       calls.
+       (create_expression_by_pieces): Fix typo.
+       (do_regular_insertion): Use debug counter here too.
+
 2008-07-14  Hans-Peter Nilsson  <hp@axis.com>
 
        PR target/35492.
index ecaf54c942d6e92008182d277407b6c969b53eb7..215074be8f92f4adecee351a047a790d90c54e3c 100644 (file)
@@ -1068,8 +1068,14 @@ fully_constant_expression (pre_expr e)
              tree const1 = get_constant_for_value_id (vrep1);
              tree result = NULL;
              if (const0 && const1)
-               result = fold_binary (nary->opcode, nary->type, const0,
-                                     const1);
+               {
+                 tree type1 = TREE_TYPE (nary->op[0]);
+                 tree type2 = TREE_TYPE (nary->op[1]);
+                 const0 = fold_convert (type1, const0);
+                 const1 = fold_convert (type2, const1);
+                 result = fold_binary (nary->opcode, nary->type, const0,
+                                       const1);
+               }
              if (result && is_gimple_min_invariant (result))
                return get_or_alloc_expr_for_constant (result);
              return e;
@@ -1084,7 +1090,12 @@ fully_constant_expression (pre_expr e)
              tree const0 = get_constant_for_value_id (vrep0);
              tree result = NULL;
              if (const0)
-               result = fold_unary (nary->opcode, nary->type, const0);
+               {
+                 tree type1 = TREE_TYPE (nary->op[0]);
+                 const0 = fold_convert (type1, const0);
+                 result = fold_unary (nary->opcode, nary->type, const0);
+               }
+             
              if (result && is_gimple_min_invariant (result))
                return get_or_alloc_expr_for_constant (result);
              return e;
@@ -2701,7 +2712,7 @@ create_expression_by_pieces (basic_block block, pre_expr expr, tree stmts,
              if (nary->opcode == POINTER_PLUS_EXPR)
                genop2 = fold_convert (sizetype, genop2);
              else
-               genop2 = fold_convert (TREE_TYPE (nary->op[0]), genop2);
+               genop2 = fold_convert (TREE_TYPE (nary->op[1]), genop2);
              
              folded = fold_build2 (nary->opcode, nary->type,
                                    genop1, genop2);
@@ -2945,10 +2956,10 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum,
              /* When eliminating casts through unions,
                 we sometimes want to convert a real to an integer,
                 which fold_convert will ICE on  */
-             if (fold_convertible_p (type, name))
+/*           if (fold_convertible_p (type, name)) */
                builtexpr = fold_convert (type, name);
-             else
-               builtexpr = convert (type, name);
+/*           else
+               builtexpr = convert (type, name);*/
 
              forcedexpr = force_gimple_operand (builtexpr,
                                                 &stmts, true,
@@ -3159,7 +3170,7 @@ do_regular_insertion (basic_block block, basic_block dom)
             already existing along every predecessor, and
             it's defined by some predecessor, it is
             partially redundant.  */
-         if (!cant_insert && !all_same && by_some)
+         if (!cant_insert && !all_same && by_some && dbg_cnt (treepre_insert))
            {
              if (insert_into_preds_of_block (block, get_expression_id (expr),
                                              avail))