https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97092
--- Comment #6 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> --- (In reply to Andrea Corallo from comment #5) > "rsandifo at gcc dot gnu.org via Gcc-bugs" <gcc-bugs@gcc.gnu.org> > writes: > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97092 > > > > --- Comment #4 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot > > gnu.org> --- > > (In reply to Andrea Corallo from comment #3) > >> Created attachment 49710 [details] > >> PR97092.patch > >> > >> What is going on is that in 'update_costs_from_allocno' we try to > >> identify the smallest mode using narrower_subreg_mode to then update the > >> costs. > >> > >> The two modes involved here are E_DImode and E_VNx2QImode, cause these > >> are not ordered we ICE in 'paradoxical_subreg_p'. > >> > >> Now I don't know if the strategy we want is: > >> > >> - In 'update_costs_from_allocno' when modes are not ordered instead of > >> calling 'narrower_subreg_mode' just keep the current one. > >> > >> - Always select the cheapest mode in terms of cost. > >> > >> The attached I'm testing implements the second. > > Hi Richard, > > thanks for commenting. > > > I think instead we should consider recomputing “mode” in each > > iteration of the loop, rather than carry over the result of > > previous iterations. I.e. use: > > > > mode = narrower_subreg_mode (ALLOCNO_MODE (cp->first), > > ALLOCNO_MODE (cp->second)); > > Are we garanteed to have ALLOCNO_MODE (cp->first) and ALLOCNO_MODE > (cp->second) always satisfying 'ordered_p'? Yeah, I think so. If the modes aren't ordered then we shouldn't create a copy between them. > I thought we select the smallest because is the cheapest, so not to use 'narrower_subreg_mode' I compared directly the costs. I think the difficulty is that for the x86 situation described in the comment, the cost for the wider mode might not be meaningful. It might be dangerous to rely on it having a larger value than the narrower (meaningful) mode.