-
Notifications
You must be signed in to change notification settings - Fork 277
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
manually const-ify shuffle arguments #1160
Conversation
r? @Amanieu (rust-highfive has picked a reviewer for you, use r? to override) |
Funny that it complains about style, in some files when I did rustfmt it caused changes in code I had not touched so I figured I'd not run rustfmt here... |
Yeah, this is also the case in |
This means we do not rely on promotion any more for these arguments
@SparrowLii Can you help with the modifications needed to |
For rustfmt, I think it's because it is inheriting the rustfmt.toml of rustc. Try creating an empty rustfmt.toml in the stdarch root. |
That didn't help; I ended up checking out the branch in a separate clone of the repo and doing the fmt there. |
I will give the corresponding changes. |
I don't think that will work, there also needs to be a simd_shuffle8_param!(a, b, <const LANE2: i32> [8 + LANE2 as u32, 1, 2, 3, 4, 5, 6, 7]), We could change the macro syntax if that helps, but the macro does need to explicitly know name and type of const parameters that the array expression depends on. (Currently only a single param is supported, but I can easily improve the macro.) |
Anyway this PR is green now. :D We don't have to land all these changes in one go, so if @SparrowLii is taking care of the remaining neon issues, that could happen in a separate PR and I think this PR could land already? |
You just need change this line to the following:
Then use |
@SparrowLii that did not entirely work, but doing this instead helped: let mut s = format!("<const {}: i32> [", fn_format[3]); I made the macros a bit easier to use so the same macro supports arrays with and without use of constants. However, the generated file still contains some incorrect functions like pub unsafe fn vdupq_laneq_p64<const N: i32>(a: poly64x2_t) -> poly64x2_t {
static_assert_imm1!(N);
simd_shuffle2!(a, a, [N as u32, N as u32])
} Here a |
I think what should work is to simply add all |
I think I found a way to forward that information to |
Ah CI is looking good. :) |
4 => simd_shuffle8!(a, b, <const LANE1: i32, const LANE2: i32> [0, 1, 2, 3, 8 + LANE2 as u32, 5, 6, 7]), | ||
5 => simd_shuffle8!(a, b, <const LANE1: i32, const LANE2: i32> [0, 1, 2, 3, 4, 8 + LANE2 as u32, 6, 7]), | ||
6 => simd_shuffle8!(a, b, <const LANE1: i32, const LANE2: i32> [0, 1, 2, 3, 4, 5, 8 + LANE2 as u32, 7]), | ||
7 => simd_shuffle8!(a, b, <const LANE1: i32, const LANE2: i32> [0, 1, 2, 3, 4, 5, 6, 8 + LANE2 as u32]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one disadvantage of this approach is that it unnecessarily adds LANE1
to the generics of the constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot ensure that the constn_declare
required by simd_shuffle*!
is consistent with the constn_declare
in the function signature, so I think it might be better to use ins:constn
and dup:constn
in the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if you can allow a comma between <constn LANE2: i32>
and the square brackets,(like simd_shuffle8_param!(a, b, <const LANE2: i32>, [8 + LANE2 as u32, 1, 2, 3, 4, 5, 6, 7])
) we can simply add another parameter after a, b
in spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot ensure that the constn_declare required by simd_shuffle*! is consistent with the constn_declare in the function signature
Well, the simd_shuffle only requires any superset of the constants to be declared. I am not sure what the cost of declaring "too much" is, it would mean the associated const has more monomorphizations -- but since the surrounding function already has that number of monomorphizations, I doubt that is a big problem.
IOW, I think the code generated currently is fine, and this can always be improved if it does turn out to be a problem.
Or if you can allow a comma
That sounds a bit hacky but I think allowing a comma is probably easy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds a bit hacky but I think allowing a comma is probably easy.
Just forget it plz. That will cause other problems (because it contains :
)
This means we do not rely on promotion any more for these arguments. Prerequisite for rust-lang/rust#85110.
However, I could not figure out what is generating these calls:
stdarch/crates/core_arch/src/aarch64/neon/generated.rs
Line 1174 in 4cc8cf6
The correspond "spec" seems to be
But I couldn't figure out how this would have to be modified to generate calls to
simd_shuffleN_param!
here.