On Fri, Jul 24, 2015 at 10:23:59AM +0100, Kyrill Tkachov wrote: > On 24/07/15 10:09, Jakub Jelinek wrote: > >On Fri, Jul 24, 2015 at 09:48:30AM +0100, Kyrill Tkachov wrote: > >>>>Bootstrapped and tested on arm, aarch64, x86_64. > >>>I think this is another case that, if at all, should be done during or > >>>right > >>>before RTL expansion and should test rtx costs. > >>Hmm, where would that be? > >That is up to discussions, all I'm saying is that match.pd when run on > >GENERIC and/or anywhere among GIMPLE passes that fold stuff is undesirable. > > > >In expr.c, with TER you can detect such patterns, in this case when > >expanding the comparison, but perhaps we want a *.pd file that would have > >rules that would be only GIMPLE and only enabled in a special pass right > >before (or very close to) expansion, that would perform such instruction > >selection. > > Wild idea, but could it be considered to have target-specific > match.pd files that can be included in the main match.pd? > That way, targets would get the benefit of getting > the target-specific folding they benefit from at the very beginning > of compilation without stepping on other targets toes.
I'd strongly prefer that isn't done. First of all, you really don't want to make target-specific foldings during generic folding (yeah, there are already cases where it is done, but we want to avoid it), or during early GIMPLE, ideally that should be late GIMPLE only where we introduce gradually more and more target dependencies. By making GIMPLE more target specific earlier, you break e.g. the offloading stuff, but also introduce target specific bugs more often to GIMPLE optimizers (these days, most GIMPLE optimizer issues (especially before vectorizer/ivopts and other target specific changes) affect all targets, or are perhaps ILP32/LP64 etc. related at most). Also, by allowing target-specific foldings, we'd end up with duplications between different target, using rtx_costs, maintaining them more accurrately and performing some generic code selections based on them IMHO is desirable. Jakub