-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply RLS to @splat builtin, eliminating its length parameter #16346
Conversation
Sema logic is missing type checks. Need to check dest ty is a vector |
Also, CI failures are because zig1 doesn't have the changes. Run |
6365adb
to
29c0910
Compare
Thanks for implementing this. Hmmmm, looking at the diff, is this change actually good? It seems kind of worse actually. Are there any more opportunities to clean up the diff so that we can see if this change actually results in more maintainable code? |
I think a key thing that would make this nicer to work with is if we can figure out RLS for arithmetic operands, but I'm still unsure what exactly such a proposal would look like |
64aad35
to
7847120
Compare
I've now pushed some new changes where I cleaned up the code as much as possible. I do agree that some parts do look a bit less readable. This is the resulting change when the result type cannot be inferred: // Before:
@splat(N, @as(T, SOME_LITERAL));
// After:
@as(@Vector(N, T), @splat(SOME_LITERAL)); In quite a few places the code is less readable because the type cannot be inferred where it probably could be. I think @mlugg is correct in that RLS for arithmetic operands would help but there are a lot of places where this wouldn't help. For example where this syntax change interacts with the new cast syntax: // Before:
@splat(len, @as(i32, @intCast(some_var)))
// After:
@as(@Vector(len, i32), @splat(@as(i32, @intCast(some_var)))) |
That case can be fixed by adding a result type for |
Thanks for further exploring it with cleanups, @antlilja. Upon reexamination, I think that this change is at worst, neutral. Given that it increases consistency with other builtins, and sometimes can reduce an awkward need to pass the element type rather than the vector type, I'm in favor of moving forward with it. |
Then I'll keep working on it. I've started implementing what mlugg suggested so it works better with the other changes to builtins. |
Resolve the result type of the splat builtin instead of requiring a length parameter.
Needed due to the breaking changes to `@splat` which are used by the self-hosted compiler. This update also includes the improvement that allows casting builtins to infer the result type through optionals and error unions.
Closes #16277
This PR removes the length parameter from the splat builtin instead resolving the result type.