On Fri, Aug 29, 2025 at 5:35 PM Robin Dapp <[email protected]> wrote: > > Thinking about it some more, it might make sense to do the sign swap tries > inside vect_gather_scatter_fn_p as well. That wouldn't pollute the callers. > > I'm still pondering how safe swapping the sign is here. > > If we have signed indices there won't be any overflow and we should be able to > switch to unsigned? In order to ensure negative values are properly > represented we need to use a pointer-sized type, though?
The optab semantically does base-ptr + (Pmode)offset * scale, so a Pmode offset should be fine to have in any sign. > For the opposite direction (unsigned -> signed) do we need a pointer-sized > type? I'd have thought a 2x-sized type suffices. I think 2x size suffices for this direction. On the patch itself I'll note I have tried to make the "early" gather/scatter check more forgiving as well, with the basic idea of not nailing down the vector type just yet. For the scale given we match it up in internal_gather_scatter_fn_supported_p I think you cannot simply use '1' in some places and another value in others. '1' might not be supported. Most ISAs require the offset vector to have the same element width than the data vector and the code generation for gather/scatter doesn't support arbitrary widening but relies on conversions to actually exist in the IL (they are usually inserted by patterns when using IFNs, but I'd like to get rid of that - another early nailing down of vector types). So it's somewhat of a difficult maze currently. I suggest you split out the unsigned vs. signed handling. What I don't like is how you defer some decisions to code generation - the decision should be done during analysis, ideally stored in the load-store data where it would be accessible to backends during costing. Richard. > -- > Regards > Robin >
