Patchwork PATCH: PR target/53647: Set proper cache values when needed

login
register
mail settings
Submitter H.J. Lu
Date June 13, 2012, 5:48 p.m.
Message ID <CAMe9rOrZEpP6dXtubEyvdY03y7R2RF=JnEEtFuBJGB5c-Zf6mQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/164733/
State New
Headers show

Comments

H.J. Lu - June 13, 2012, 5:48 p.m.
On Wed, Jun 13, 2012 at 10:40 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Wed, Jun 13, 2012 at 4:47 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>
>> On i386, ix86_size_cost will be used for -Os, which has zero for
>> simultaneous_prefetches, prefetch_block, l1_cache_size and l2_cache_size.
>> This patch adds ix86_tune_cost and uses it for simultaneous_prefetches,
>> prefetch_block, l1_cache_size and l2_cache_size if ones from ix86_cost
>> are zero.  OK to install?
>>
>> 2012-06-13  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>        PR target/53647
>>        * config/i386/i386.c (ix86_tune_cost): New variable.
>>        (ix86_option_override_internal): Set ix86_tune_cost.  Use
>>        ix86_tune_cost for simultaneous_prefetches, prefetch_block,
>>        l1_cache_size and l2_cache_size if ones from ix86_cost are
>>        zero.
>>
>> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>> index 13755f4..2e64d55 100644
>> --- a/gcc/config/i386/i386.c
>> +++ b/gcc/config/i386/i386.c
>> @@ -1874,6 +1874,10 @@ struct processor_costs generic32_cost = {
>>   1,                                   /* cond_not_taken_branch_cost.  */
>>  };
>>
>> +/* Set by -mtune.  */
>> +const struct processor_costs *ix86_tune_cost = &pentium_cost;
>> +
>> +/* Set by -mtune or -Os.  */
>
> /* Set by -mtune, overridden by -Os.  */
>
>>  const struct processor_costs *ix86_cost = &pentium_cost;
>
> We probably don't need to initialize these variables, but won't hurt.
>
> Just set these params directly from ix86_tune_costs. We know these are
> the same, unless -Os clears them.
>
> OK with these changes.
>
> Thanks,
> Uros.

This is the patch I checked in.

Thanks.

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 13755f4..04a5edc 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -1874,6 +1874,10 @@  struct processor_costs generic32_cost = {
   1,					/* cond_not_taken_branch_cost.  */
 };

+/* Set by -mtune.  */
+const struct processor_costs *ix86_tune_cost = &pentium_cost;
+
+/* Set by -mtune or -Os.  */
 const struct processor_costs *ix86_cost = &pentium_cost;

 /* Processor feature/optimization bitmasks.  */
@@ -3546,10 +3550,11 @@  ix86_option_override_internal (bool main_args_p)
 	flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
     }

+  ix86_tune_cost = processor_target_table[ix86_tune].cost;
   if (optimize_size)
     ix86_cost = &ix86_size_cost;
   else
-    ix86_cost = processor_target_table[ix86_tune].cost;
+    ix86_cost = ix86_tune_cost;

   /* Arrange to set up i386_stack_locals for all functions.  */
   init_machine_status = ix86_init_machine_status;
@@ -3794,16 +3799,19 @@  ix86_option_override_internal (bool main_args_p)
     flag_schedule_insns_after_reload = flag_schedule_insns = 0;

   maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES,
-			 ix86_cost->simultaneous_prefetches,
+			 ix86_tune_cost->simultaneous_prefetches,
 			 global_options.x_param_values,
 			 global_options_set.x_param_values);
-  maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE, ix86_cost->prefetch_block,
+  maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE,
+			 ix86_tune_cost->prefetch_block,
 			 global_options.x_param_values,
 			 global_options_set.x_param_values);
-  maybe_set_param_value (PARAM_L1_CACHE_SIZE, ix86_cost->l1_cache_size,
+  maybe_set_param_value (PARAM_L1_CACHE_SIZE,
+			 ix86_tune_cost->l1_cache_size,
 			 global_options.x_param_values,
 			 global_options_set.x_param_values);
-  maybe_set_param_value (PARAM_L2_CACHE_SIZE, ix86_cost->l2_cache_size,
+  maybe_set_param_value (PARAM_L2_CACHE_SIZE,
+			 ix86_tune_cost->l2_cache_size,
 			 global_options.x_param_values,
 			 global_options_set.x_param_values);