Patchwork Function Multiversioning Bug, checking for function versions

login
register
mail settings
Submitter Sriraman Tallam
Date Jan. 3, 2013, 1 a.m.
Message ID <CAAs8HmzXHc2F2x9h0Qp5Uo3yk4VRf2pc8g0UxHSVQWfQVmkC1Q@mail.gmail.com>
Download mbox | patch
Permalink /patch/209166/
State New
Headers show

Comments

Sriraman Tallam - Jan. 3, 2013, 1 a.m.
On Wed, Jan 2, 2013 at 1:01 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Jan 02, 2013 at 12:23:45PM -0800, Sriraman Tallam wrote:
>> --- config/i386/i386.c  (revision 194817)
>> +++ config/i386/i386.c  (working copy)
>> @@ -29290,7 +29290,7 @@ ix86_get_function_versions_dispatcher (void *decl)
>>
>>    /* Set the dispatcher for all the versions.  */
>>    it_v = default_version_info;
>> -  while (it_v->next != NULL)
>> +  while (it_v != NULL)
>>      {
>>        it_v->dispatcher_resolver = dispatch_decl;
>>        it_v = it_v->next;
>> @@ -29626,8 +29626,8 @@ fold_builtin_cpu (tree fndecl, tree *args)
>>        {"avx2",   F_AVX2}
>>      };
>>
>> -  static tree __processor_model_type = NULL_TREE;
>> -  static tree __cpu_model_var = NULL_TREE;
>> +  tree __processor_model_type = NULL_TREE;
>> +  tree __cpu_model_var = NULL_TREE;
>>
>>    if (__processor_model_type == NULL_TREE)
>>      __processor_model_type = build_processor_model_struct ();
>
> If __processor_model_type is always NULL_TREE above, then you should write
>   tree __processor_model_type = build_processor_model_struct ();
> rather than the extra if with an always true condition.

Submitted this patch to fix this.

        * config/i386/i386.c (fold_builtin_cpu): Remove unnecessary checks for
        NULL.


Thanks,
-Sri.


>
>         Jakub

Patch

--- config/i386/i386.c (revision 194827)
+++ config/i386/i386.c (working copy)
@@ -29626,16 +29626,10 @@  fold_builtin_cpu (tree fndecl, tree *args)
       {"avx2",   F_AVX2}
     };

-  tree __processor_model_type = NULL_TREE;
-  tree __cpu_model_var = NULL_TREE;
+  tree __processor_model_type = build_processor_model_struct ();
+  tree __cpu_model_var = make_var_decl (__processor_model_type,
+                                                              "__cpu_model");

-  if (__processor_model_type == NULL_TREE)
-    __processor_model_type = build_processor_model_struct ();
-
-  if (__cpu_model_var == NULL_TREE)
-    __cpu_model_var = make_var_decl (__processor_model_type,
-                                                         "__cpu_model");
-
   gcc_assert ((args != NULL) && (*args != NULL));

   param_string_cst = *args;