On Fri, Nov 8, 2013 at 10:06 PM, Richard Biener
<richard.guent...@gmail.com> wrote:
> On Fri, Nov 8, 2013 at 2:41 PM, bin.cheng <bin.ch...@arm.com> wrote:
>> Hi,
>> This patch refactors force_expr_to_var_cost and handles type conversion
>> along with other tree nodes.  It is split from the patch posted at
>> http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00546.html
>> Bootstrap and test with the patch lowering address expressions on
>> x86/x86_64/arm.  Is it OK?
>
> ENOPATCH
>
Attached here.
I think it should be stated that this patch and the lowering one are
logically one because we rely on this patch to compute cost of lowered
address expression like "&arr + offset".
Moreover, address_cost on x86/x86_64 (is 1) are small, so this patch
has small impact on these two targets.  While address_cost on arm (is
9) is non-trivial, it has greater impact on ARM.  The statement is in
line with various benchmark data.

Thanks,
bin
-- 
Best Regards.
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c  (revision 204498)
+++ gcc/tree-ssa-loop-ivopts.c  (working copy)
@@ -3608,30 +3608,13 @@ force_expr_to_var_cost (tree expr, bool speed)
       op1 = TREE_OPERAND (expr, 1);
       STRIP_NOPS (op0);
       STRIP_NOPS (op1);
-
-      if (is_gimple_val (op0))
-       cost0 = no_cost;
-      else
-       cost0 = force_expr_to_var_cost (op0, speed);
-
-      if (is_gimple_val (op1))
-       cost1 = no_cost;
-      else
-       cost1 = force_expr_to_var_cost (op1, speed);
-
       break;
 
+    CASE_CONVERT:
     case NEGATE_EXPR:
       op0 = TREE_OPERAND (expr, 0);
       STRIP_NOPS (op0);
       op1 = NULL_TREE;
-
-      if (is_gimple_val (op0))
-       cost0 = no_cost;
-      else
-       cost0 = force_expr_to_var_cost (op0, speed);
-
-      cost1 = no_cost;
       break;
 
     default:
@@ -3639,6 +3622,18 @@ force_expr_to_var_cost (tree expr, bool speed)
       return new_cost (target_spill_cost[speed], 0);
     }
 
+  if (op0 == NULL_TREE
+      || TREE_CODE (op0) == SSA_NAME || CONSTANT_CLASS_P (op0))
+    cost0 = no_cost;
+  else
+    cost0 = force_expr_to_var_cost (op0, speed);
+
+  if (op1 == NULL_TREE
+      || TREE_CODE (op1) == SSA_NAME || CONSTANT_CLASS_P (op1))
+    cost1 = no_cost;
+  else
+    cost1 = force_expr_to_var_cost (op1, speed);
+
   mode = TYPE_MODE (TREE_TYPE (expr));
   switch (TREE_CODE (expr))
     {
@@ -3662,8 +3657,19 @@ force_expr_to_var_cost (tree expr, bool speed)
                                     speed, &sa_cost))
             return sa_cost;
         }
+
       break;
 
+    CASE_CONVERT:
+      {
+       tree inner_mode, outer_mode;
+       outer_mode = TREE_TYPE (expr);
+       inner_mode = TREE_TYPE (op0);
+       cost = new_cost (convert_cost (TYPE_MODE (outer_mode),
+                                      TYPE_MODE (inner_mode), speed), 0);
+      }
+      break;
+
     case MULT_EXPR:
       if (cst_and_fits_in_hwi (op0))
        cost = new_cost (mult_by_coeff_cost (int_cst_value (op0),

Reply via email to