On Fri, Jan 14, 2022 at 9:27 AM Giovanni Mascellani gmascellani@codeweavers.com wrote:
Hi,
Il 13/01/22 19:57, Zebediah Figura (she/her) ha scritto:
This suggests to me that what we should probably do is actually "flatten" the initializer beforehand. That is, generate load and swizzle instructions such that every initializer argument is a scalar. E.g. the above would become {1, 2, u.x, u.y, u.z, u.w, 3, 4}. This generates a lot of unnecessary scalar ops, but I think we want a vectorization pass anyway.
Fully agreed. Initially I thought this could arrive later, but I'm convincing myself that if we (meaning, in this case, Francisco :-P ) bite the bullet and immediately write the flattening, it becomes easier to check the rest and we have cleaner code.
Yes, same for me. Going flat (tm) should make everything nicer (except the resulting IR, but for that we have different tools).
As I already said, there are cases that are treated a bit differently, like "float3 x = float4(1, 2, 3, 4)", in which it is sensible to fall back to a simple assignment.
Right, it shouldn't be too complicated to special case those. This separate path can come after the generic / complex one, it's not like we're currently handling those initializers correctly anyway.