On Thu, Aug 27, 2020 at 03:07:59PM +0200, Richard Biener wrote: > > Also, isn't the pass also useful for TARGET_AVX and above (but in that case > > only if it is a simple memory load)? Or are avx/avx2 broadcast slower than > > full vector loads? > > > > As Jeff wrote, I wonder if when successfully replacing those pool constants > > the old constant pool entries will be omitted. > > > > Another thing I wonder about is whether more analysis shouldn't be used. > > E.g. if the constant pool entry is already emitted into .rodata anyway > > (e.g. some earlier function needed it), using the broadcast will mean > > actually larger .rodata. If {1to8} and similar is as fast as reading all > > the same elements from memory (or faster), perhaps in that case it should > > broadcast from the first element of the existing constant pool full vector > > rather than creating a new one. > > And similarly, perhaps the function should look at all constant pool entries > > in the current function (not yet emitted into .rodata) and if it would > > succeed for some and not for others, either use broadcast from its first > > element or not perform it for the others too. > > IIRC I once implemented this (re-using vector constant components > for non-vector pool entries) but it was quite hackish and never merged > it seems.
If the generic constant pool code could do it, it would of course simplify this pass. Not sure if the case where earlier function emits already some smaller constant and later function needs a CONST_VECTOR containing that can be handled at all (probably not), but if the same function has both scalar pool entries and CONST_VECTOR ones that contain those, or already emitted CONST_VECTOR pool entry has them, it shouldn't be that hard, at least for targets with symbol aliases, e.g. by using .LC33 = .LC24 or .LC34 = .LC24 + 8 where .LC33 or .LC34 would be the scalar pool entry label and .LC24 CONST_VECTOR containing those. Seems constant pool marking is performed during mark_constant_pool called during final from assemble_start_function or assemble_end_function, so if the pass replaces the constants before final and the constants are unused, they won't be emitted. Jakub