On Tue, Feb 12, 2013 at 09:58:38AM -0600, Aldy Hernandez wrote: > OK for trunk?
I'd still prefer Richard to chime in, I'm really not familiar enough with MIPS switchable target stuff. > +/* Recompute the optabs. If they have changed, save the new set of > + optabs in the optimization node OPTNODE. */ > + > +void > +save_optabs_if_changed (tree optnode) > +{ > + struct target_optabs *save_target_optabs = this_target_optabs; > + struct target_optabs *tmp_target_optabs = XCNEW (struct target_optabs); > + > + /* Generate a new set of optabs into tmp_target_optabs. */ > + this_target_optabs = tmp_target_optabs; > + init_all_optabs (); > + this_target_optabs = save_target_optabs; > + > + /* If the optabs changed, record it in the node. */ > + if (memcmp (tmp_target_optabs, &default_target_optabs, > + sizeof (struct target_optabs))) > + { > + /* ?? An existing entry in TREE_OPTIMIZATION_OPTABS indicates > + multiple ((optimize)) attributes for the same function. Is > + this even valid? For now, just clobber the existing entry > + with the new optabs. */ > + if (TREE_OPTIMIZATION_OPTABS (optnode)) > + XDELETE (TREE_OPTIMIZATION_OPTABS (optnode)); I wonder if this necessarily won't mean that if TREE_OPTIMIZATION_OPTABS is non-NULL, then memcmp (tmp_target_optabs, TREE_OPTIMIZATION_OPTABS (optnode), sizeof (*tmp_target_optabs)) == 0. Because, optimization nodes are only shared if they contain the same set of all options. Multiple optimize attributes seems to be valid, see what handle_optimize_attribute says on them, but they together either create a fresh optimization node which certainly won't have TREE_OPTIMIZATION_OPTABS set, or they return one older, but that should be already initialized to the same thing. So perhaps start the function with if (TREE_OPTIMIZATION_OPTABS (optnode)) return; ? I.e., if you have multiple functions with the same optimization node, there is no need to do init_all_optabs again and again. Perhaps we want to have a flag whether TREE_OPTIMIZATION_OPTABS has been computed already, and don't call save_optabs_if_changed if already set, or add some magic value for TREE_OPTIMIZATION_OPTABS, where e.g. NULL would mean not computed yet, the special magic value would mean the default and other values the special optabs? Perhaps the magic value could be just &default_target_optabs... Jakub