From patchwork Thu Jan 3 01:00:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Function Multiversioning Bug, checking for function versions Date: Wed, 02 Jan 2013 15:00:27 -0000 From: Sriraman Tallam X-Patchwork-Id: 209166 Message-Id: To: Jakub Jelinek Cc: Andreas Schwab , GCC Patches , "H.J. Lu" , "Zamyatin, Igor" , David Li On Wed, Jan 2, 2013 at 1:01 PM, Jakub Jelinek 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 --- 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;