On 10/28/2011 05:41 AM, Michael Zolotukhin wrote: >> > +/* Target hook. Returns rtx of mode MODE with promoted value VAL, that is >> > + supposed to represent one byte. MODE could be a vector mode. >> > + Example: >> > + 1) VAL = const_int (0xAB), mode = SImode, >> > + the result is const_int (0xABABABAB). >> > >> > This can be handled in machine independent way, right? >> > >> > + 2) if VAL isn't const, then the result will be the result of >> > MUL-instruction >> > + of VAL and const_int (0x01010101) (for SImode). */ >> > >> > This would probably go better as named expansion pattern, like we do for >> > other >> > machine description interfaces. > I don't think it could be done in machine-independent way - e.g. if > AVX is available, we could use broadcast-instructions, if not - we > need to use multiply-instructions, on other architectures there > probably some other more efficient ways to duplicate byte value across > the entire vector register. So IMO it's a good place to have a hook. > >
Certainly it can be done machine-independently. See expand_vector_broadcast in optabs.c for a start. r~