-
Notifications
You must be signed in to change notification settings - Fork 13.3k
add core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}
#137447
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
Conversation
right so this works with the LLVM implementation (so the fallback is not used), is there some try job that would run |
you should be able to just |
I don't think that runs this test? or it does work. I've added a commit that disables the custom LLVM implementation, so the fallback should be used. Locally that errors with
|
This comment has been minimized.
This comment has been minimized.
odd. |
It looks like something you could make If so, you can test the fallback in CTFE. (Might need |
none of that solves the actual problem of rustc somehow believing that this intrinsic must be overwritten by the backend. The only place where LLVM matches on the I can mark the functions as const (though extract needs to do a |
aa1b187
to
dbda1dc
Compare
This comment has been minimized.
This comment has been minimized.
right, with the standard imports it's now hitting the LLVM codegen test, hence the fallback is actually used (but generates something different from what the test expects). So, that should be sufficient right? Then the logic that prevents the LLVM implementation from being used can be removed and the hard work here should be done. |
dbda1dc
to
47d48fb
Compare
Some changes occurred to the platform-builtins intrinsics. Make sure the cc @antoyo, @GuillaumeGomez, @bjorn3, @calebzulawski, @programmerjake Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @rust-lang/wg-const-eval |
No, Miri has its own test suite.
You're mixing up a few things here.^^ CTFE doesn't care about If you add that attribute, note that it has a semantic meaning! It means the fallback must fully cover every case of the spec, including UB and non-determinism. What would the fallback implementation even be here, given that all the types are unknown? |
Ah, I have found the old implementations in the diffs. unsafe { (&mut x as *mut T as *mut U).add(idx as usize).write(val) } Adding IOW, it would not be correct to specify the intrinsic as |
How? The allocation would be the SIMD type itself, wouldn't it? Since that moves by-value into the function. |
I suppose it needs a copy bound, but |
Ah, fair, I forgot that this is not a reference/pointer. |
not 100% following here: should I add |
I think I would prefer a proper implementation in Miri. That should be trivial as the implementation is the same as the non-dyn variants. Will provide some links when I am back at a keyboard.
|
As far as I can tell, the implementation should be a trivial matter of adding
and the same with |
well there is some related discussion over on zullip on whether this is the best approach #project-portable-simd > simd extraction/insertion with a non-`const` index I think we've sort of settled on this being the best approach at the moment, but idk maybe it needs more discussion still. |
well I believe this is ready and there's not been any further discussion I think this just needs review at this point @rustbot ready |
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.
I think this is mostly fine, but did have some requested cleanup that I think would be good.
9239a91
to
82f321d
Compare
@rustbot ready |
@@ -0,0 +1,75 @@ | |||
//@compile-flags: -C no-prepopulate-passes -Z merge-functions=disabled |
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.
You probably still want
//@compile-flags: -C no-prepopulate-passes -Z merge-functions=disabled | |
//@compile-flags: -C opt-level=3 -C no-prepopulate-passes |
so that rust always treats it as optimized, emitting things like noundef
parameter attributes, so that (as you say) you get consistent output no matter the default optimization level.
-C no-prepopulate-passes
just turns off the LLVM passes so that it doesn't change what rustc emitted.
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.
(Which also means it turns off the function merging pass you so you don't need to worry about -Z merge-function
.)
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.
Got it, fixed that
82f321d
to
59c5533
Compare
@bors r+ |
Rollup of 12 pull requests Successful merges: - rust-lang#137447 (add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`) - rust-lang#138182 (rustc_target: update x86_win64 to match the documented calling convention for f128) - rust-lang#138682 (Allow drivers to supply a list of extra symbols to intern) - rust-lang#138904 (Test linking and running `no_std` binaries) - rust-lang#138998 (Don't suggest the use of `impl Trait` in closure parameter) - rust-lang#139447 (doc changes: debug assertions -> overflow checks) - rust-lang#139469 (Introduce a `//@ needs-crate-type` compiletest directive) - rust-lang#139564 (Deeply normalize obligations in `BestObligation` folder) - rust-lang#139574 (bootstrap: improve `channel` handling) - rust-lang#139600 (Update `compiler-builtins` to 0.1.153) - rust-lang#139641 (Allow parenthesis around inferred array lengths) - rust-lang#139654 (Improve `AssocItem::descr`.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#137447 - folkertdev:simd-extract-insert-dyn, r=scottmcm add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}` fixes rust-lang#137372 adds `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`, which contrary to their non-dyn counterparts allow a non-const index. Many platforms (but notably not x86_64 or aarch64) have dedicated instructions for this operation, which stdarch can emit with this change. Future work is to also make the `Index` operation on the `Simd` type emit this operation, but the intrinsic can't be used directly. We'll need some MIR shenanigans for that. r? `@ghost`
…, r=scottmcm add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}` fixes rust-lang#137372 adds `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`, which contrary to their non-dyn counterparts allow a non-const index. Many platforms (but notably not x86_64 or aarch64) have dedicated instructions for this operation, which stdarch can emit with this change. Future work is to also make the `Index` operation on the `Simd` type emit this operation, but the intrinsic can't be used directly. We'll need some MIR shenanigans for that. r? `@ghost`
fixes #137372
adds
core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}
, which contrary to their non-dyn counterparts allow a non-const index. Many platforms (but notably not x86_64 or aarch64) have dedicated instructions for this operation, which stdarch can emit with this change.Future work is to also make the
Index
operation on theSimd
type emit this operation, but the intrinsic can't be used directly. We'll need some MIR shenanigans for that.r? @ghost