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

rustc: Add an unstable `simd_select_bitmask` intrinsic #56789

Merged
merged 1 commit into from Dec 16, 2018

Conversation

Projects
None yet
6 participants
@alexcrichton
Copy link
Member

alexcrichton commented Dec 13, 2018

This is going to be required for binding a number of AVX-512 intrinsics
in the stdsimd repository, and this intrinsic is the same as
simd_select except that it takes a bitmask as the first argument
instead of a SIMD vector. This bitmask is then transmuted into a <NN x i8> argument, depending on how many bits it is.

cc rust-lang-nursery/stdsimd#310

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Dec 13, 2018

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@rkruppe
Copy link
Contributor

rkruppe left a comment

Two nits, but otherwise LGTM

Show resolved Hide resolved src/librustc_codegen_llvm/intrinsic.rs Outdated
let in_ty = arg_tys[0];
let m_len = match in_ty.sty {
ty::Int(i) => i.bit_width().unwrap(),
ty::Uint(i) => i.bit_width().unwrap(),

This comment has been minimized.

@rkruppe

rkruppe Dec 13, 2018

Contributor

I think this will crash with usize/isize? Probably not a big issue but could be avoided by computing the layout.

This comment has been minimized.

@alexcrichton

alexcrichton Dec 13, 2018

Member

It will indeed! That was semi-intentional, but I'll leave a comment in case a future reader is curious

This comment has been minimized.

@gnzlbg

gnzlbg Dec 13, 2018

Contributor

Might be better to properly error here?

This comment has been minimized.

@alexcrichton

alexcrichton Dec 14, 2018

Member

Hm perhaps yeah, but this is all internal anyway so I don't think we really need to go too far out of our way...

@alexcrichton alexcrichton force-pushed the alexcrichton:simd_select_bitmask branch from 72aebb1 to 5087aef Dec 13, 2018

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 13, 2018

@bors: r=rkruppe

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 13, 2018

📌 Commit 5087aef has been approved by rkruppe

@gnzlbg

gnzlbg approved these changes Dec 13, 2018

Copy link
Contributor

gnzlbg left a comment

LGTM.

//~^ ERROR `f32` is not an integral type

simd_select_bitmask("x", x, x);
//~^ ERROR `&str` is not an integral type

This comment has been minimized.

@gnzlbg

gnzlbg Dec 13, 2018

Contributor

Might want to add a test for when the vector is not a SIMD type (probably for simd_select as well).

This comment has been minimized.

@alexcrichton

alexcrichton Dec 14, 2018

Member

I think #[repr(simd)] is gating that, right?

This comment has been minimized.

@rkruppe

rkruppe Dec 14, 2018

Contributor

I think @gnzlbg means the case when the second/third argument is not a repr(simd) type. That would exercise the require_simd! check in the intrinsic implementation.

This comment has been minimized.

@alexcrichton

alexcrichton Dec 14, 2018

Member

Ah indeed, tests added now!

let in_ty = arg_tys[0];
let m_len = match in_ty.sty {
ty::Int(i) => i.bit_width().unwrap(),
ty::Uint(i) => i.bit_width().unwrap(),

This comment has been minimized.

@gnzlbg

gnzlbg Dec 13, 2018

Contributor

Might be better to properly error here?

Show resolved Hide resolved src/librustc_codegen_llvm/intrinsic.rs Outdated

kennytm added a commit to kennytm/rust that referenced this pull request Dec 14, 2018

Rollup merge of rust-lang#56789 - alexcrichton:simd_select_bitmask, r…
…=rkruppe

rustc: Add an unstable `simd_select_bitmask` intrinsic

This is going to be required for binding a number of AVX-512 intrinsics
in the `stdsimd` repository, and this intrinsic is the same as
`simd_select` except that it takes a bitmask as the first argument
instead of a SIMD vector. This bitmask is then transmuted into a `<NN x
i8>` argument, depending on how many bits it is.

cc rust-lang-nursery/stdsimd#310

bors added a commit that referenced this pull request Dec 14, 2018

Auto merge of #56803 - kennytm:rollup, r=kennytm
Rollup of 36 pull requests

Successful merges:

 - #56203 (Add lint for items deprecated in future)
 - #56343 (Remove not used mod)
 - #56439 (Clearer error message for dead assign)
 - #56490 (Add checked_add method to Instant time type)
 - #56507 (polonius tweaks)
 - #56562 (Update libc version required by rustc)
 - #56600 (bootstrap: fix edition)
 - #56609 (Unconditionally emit the target-cpu LLVM attribute.)
 - #56658 (Add non-panicking `maybe_new_parser_from_file` variant)
 - #56672 (Document time of back operations of a Linked List)
 - #56677 (#[must_use] on traits in stdlib)
 - #56679 (overhaul external doc attribute diagnostics)
 - #56691 (fix install broken link)
 - #56695 (Fix irrefutable matches on integer ranges)
 - #56699 (Use a `newtype_index!` within `Symbol`.)
 - #56702 ([self-profiler] Add column for percent of total time)
 - #56708 (Remove some unnecessary feature gates)
 - #56709 (Remove unneeded extra chars to reduce search-index size)
 - #56710 (Always set the RDRAND and RDSEED features on SGX)
 - #56713 (Test capacity of ZST vector)
 - #56718 (Use libbacktrace pretty-printing)
 - #56725 (fix rust-lang/rust issue #50583)
 - #56731 (Add missing urls in ffi module docs)
 - #56738 (Fix private_no_mangle_fns message grammar)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56744 (specialize: remove Boxes used by Children::insert)
 - #56746 (Add test of current behavior (infer free region within closure body))
 - #56747 (target: remove Box returned by get_targets)
 - #56749 (x86: Add the `adx` target feature to whitelist)
 - #56751 (Allow ptr::hash to accept fat pointers)
 - #56755 (Account for `impl Trait` when suggesting lifetime)
 - #56756 (Disable btree pretty-printers on older gdbs)
 - #56758 (Add short emoji status to toolstate updates)
 - #56760 (Deduplicate unsatisfied trait bounds)
 - #56769 (Add x86_64-unknown-uefi target)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)

bors added a commit that referenced this pull request Dec 14, 2018

Auto merge of #56803 - kennytm:rollup, r=kennytm
Rollup of 36 pull requests

Successful merges:

 - #56203 (Add lint for items deprecated in future)
 - #56343 (Remove not used mod)
 - #56439 (Clearer error message for dead assign)
 - #56490 (Add checked_add method to Instant time type)
 - #56507 (polonius tweaks)
 - #56562 (Update libc version required by rustc)
 - #56600 (bootstrap: fix edition)
 - #56609 (Unconditionally emit the target-cpu LLVM attribute.)
 - #56658 (Add non-panicking `maybe_new_parser_from_file` variant)
 - #56672 (Document time of back operations of a Linked List)
 - #56677 (#[must_use] on traits in stdlib)
 - #56679 (overhaul external doc attribute diagnostics)
 - #56691 (fix install broken link)
 - #56695 (Fix irrefutable matches on integer ranges)
 - #56699 (Use a `newtype_index!` within `Symbol`.)
 - #56702 ([self-profiler] Add column for percent of total time)
 - #56708 (Remove some unnecessary feature gates)
 - #56709 (Remove unneeded extra chars to reduce search-index size)
 - #56710 (Always set the RDRAND and RDSEED features on SGX)
 - #56713 (Test capacity of ZST vector)
 - #56718 (Use libbacktrace pretty-printing)
 - #56725 (fix rust-lang/rust issue #50583)
 - #56731 (Add missing urls in ffi module docs)
 - #56738 (Fix private_no_mangle_fns message grammar)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56744 (specialize: remove Boxes used by Children::insert)
 - #56746 (Add test of current behavior (infer free region within closure body))
 - #56747 (target: remove Box returned by get_targets)
 - #56749 (x86: Add the `adx` target feature to whitelist)
 - #56751 (Allow ptr::hash to accept fat pointers)
 - #56755 (Account for `impl Trait` when suggesting lifetime)
 - #56756 (Disable btree pretty-printers on older gdbs)
 - #56758 (Add short emoji status to toolstate updates)
 - #56760 (Deduplicate unsatisfied trait bounds)
 - #56769 (Add x86_64-unknown-uefi target)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)

kennytm added a commit to kennytm/rust that referenced this pull request Dec 14, 2018

Rollup merge of rust-lang#56789 - alexcrichton:simd_select_bitmask, r…
…=rkruppe

rustc: Add an unstable `simd_select_bitmask` intrinsic

This is going to be required for binding a number of AVX-512 intrinsics
in the `stdsimd` repository, and this intrinsic is the same as
`simd_select` except that it takes a bitmask as the first argument
instead of a SIMD vector. This bitmask is then transmuted into a `<NN x
i8>` argument, depending on how many bits it is.

cc rust-lang-nursery/stdsimd#310

kennytm added a commit to kennytm/rust that referenced this pull request Dec 14, 2018

Rollup merge of rust-lang#56789 - alexcrichton:simd_select_bitmask, r…
…=rkruppe

rustc: Add an unstable `simd_select_bitmask` intrinsic

This is going to be required for binding a number of AVX-512 intrinsics
in the `stdsimd` repository, and this intrinsic is the same as
`simd_select` except that it takes a bitmask as the first argument
instead of a SIMD vector. This bitmask is then transmuted into a `<NN x
i8>` argument, depending on how many bits it is.

cc rust-lang-nursery/stdsimd#310

bors added a commit that referenced this pull request Dec 14, 2018

Auto merge of #56818 - kennytm:rollup-2, r=kennytm
Rollup of 14 pull requests (first batch)

Successful merges:

 - #56562 (Update libc version required by rustc)
 - #56609 (Unconditionally emit the target-cpu LLVM attribute.)
 - #56637 (rustdoc: Fix local reexports of proc macros)
 - #56658 (Add non-panicking `maybe_new_parser_from_file` variant)
 - #56695 (Fix irrefutable matches on integer ranges)
 - #56699 (Use a `newtype_index!` within `Symbol`.)
 - #56702 ([self-profiler] Add column for percent of total time)
 - #56708 (Remove some unnecessary feature gates)
 - #56709 (Remove unneeded extra chars to reduce search-index size)
 - #56744 (specialize: remove Boxes used by Children::insert)
 - #56748 (Update panic message to be clearer about env-vars)
 - #56749 (x86: Add the `adx` target feature to whitelist)
 - #56756 (Disable btree pretty-printers on older gdbs)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)

r? @ghost

@alexcrichton alexcrichton force-pushed the alexcrichton:simd_select_bitmask branch from 5087aef to c6b645c Dec 14, 2018

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 14, 2018

@bors: r=rkruppe

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 14, 2018

📌 Commit c6b645c has been approved by rkruppe

@alexcrichton alexcrichton force-pushed the alexcrichton:simd_select_bitmask branch from c6b645c to bb31d60 Dec 14, 2018

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 14, 2018

@bors: r=rkruppe

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 14, 2018

📌 Commit bb31d60 has been approved by rkruppe

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 14, 2018

☔️ The latest upstream changes (presumably #56818) made this pull request unmergeable. Please resolve the merge conflicts.

rustc: Add an unstable `simd_select_bitmask` intrinsic
This is going to be required for binding a number of AVX-512 intrinsics
in the `stdsimd` repository, and this intrinsic is the same as
`simd_select` except that it takes a bitmask as the first argument
instead of a SIMD vector. This bitmask is then transmuted into a `<NN x
i8>` argument, depending on how many bits it is.

cc rust-lang-nursery/stdsimd#310

@alexcrichton alexcrichton force-pushed the alexcrichton:simd_select_bitmask branch from bb31d60 to ceee7f3 Dec 14, 2018

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 14, 2018

@bors: r=rkruppe

Part of this landed in #56818 but I'd force pushed since this was rolled up, so this now includes just changes since the rollup

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 14, 2018

📌 Commit ceee7f3 has been approved by rkruppe

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 15, 2018

@bors: rollup

Centril added a commit to Centril/rust that referenced this pull request Dec 16, 2018

Rollup merge of rust-lang#56789 - alexcrichton:simd_select_bitmask, r…
…=rkruppe

rustc: Add an unstable `simd_select_bitmask` intrinsic

This is going to be required for binding a number of AVX-512 intrinsics
in the `stdsimd` repository, and this intrinsic is the same as
`simd_select` except that it takes a bitmask as the first argument
instead of a SIMD vector. This bitmask is then transmuted into a `<NN x
i8>` argument, depending on how many bits it is.

cc rust-lang-nursery/stdsimd#310

bors added a commit that referenced this pull request Dec 16, 2018

Auto merge of #56873 - Centril:rollup, r=Centril
Rollup of 22 pull requests

Successful merges:

 - #53506 (Documentation for impl From for AtomicBool and other Atomic types)
 - #56343 (Remove not used mod)
 - #56439 (Clearer error message for dead assign)
 - #56640 (Add FreeBSD unsigned char platforms to std::os::raw)
 - #56647 (Rework treatment of `$crate` in procedural macros)
 - #56648 (Fix BTreeMap UB)
 - #56672 (Document time of back operations of a Linked List)
 - #56706 (Make `const unsafe fn` bodies `unsafe`)
 - #56737 (`TokenStream` improvements)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56761 (Suggest using `.display()` when trying to print a `Path`)
 - #56781 (Update LLVM submodule)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)
 - #56790 (Make RValue::Discriminant a normal Shallow read)
 - #56793 (rustdoc: look for comments when scraping attributes/crates from doctests)
 - #56826 (rustc: Add the `cmpxchg16b` target feature on x86/x86_64)
 - #56832 (std: Use `rustc_demangle` from crates.io)
 - #56844 (Improve CSS rule)
 - #56850 (Fixed issue with using `Self` ctor in typedefs)
 - #56855 (Remove u8 cttz hack)
 - #56857 (Fix a small mistake regarding NaNs in a deprecation message)
 - #56858 (Fix doc of `std::fs::canonicalize`)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Dec 16, 2018

Rollup merge of rust-lang#56789 - alexcrichton:simd_select_bitmask, r…
…=rkruppe

rustc: Add an unstable `simd_select_bitmask` intrinsic

This is going to be required for binding a number of AVX-512 intrinsics
in the `stdsimd` repository, and this intrinsic is the same as
`simd_select` except that it takes a bitmask as the first argument
instead of a SIMD vector. This bitmask is then transmuted into a `<NN x
i8>` argument, depending on how many bits it is.

cc rust-lang-nursery/stdsimd#310

bors added a commit that referenced this pull request Dec 16, 2018

Auto merge of #56875 - Centril:rollup, r=Centril
Rollup of 20 pull requests

Successful merges:

 - #53506 (Documentation for impl From for AtomicBool and other Atomic types)
 - #56343 (Remove not used mod)
 - #56439 (Clearer error message for dead assign)
 - #56640 (Add FreeBSD unsigned char platforms to std::os::raw)
 - #56648 (Fix BTreeMap UB)
 - #56672 (Document time of back operations of a Linked List)
 - #56706 (Make `const unsafe fn` bodies `unsafe`)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56761 (Suggest using `.display()` when trying to print a `Path`)
 - #56781 (Update LLVM submodule)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)
 - #56790 (Make RValue::Discriminant a normal Shallow read)
 - #56793 (rustdoc: look for comments when scraping attributes/crates from doctests)
 - #56826 (rustc: Add the `cmpxchg16b` target feature on x86/x86_64)
 - #56832 (std: Use `rustc_demangle` from crates.io)
 - #56844 (Improve CSS rule)
 - #56850 (Fixed issue with using `Self` ctor in typedefs)
 - #56855 (Remove u8 cttz hack)
 - #56857 (Fix a small mistake regarding NaNs in a deprecation message)
 - #56858 (Fix doc of `std::fs::canonicalize`)

Failed merges:

 - #56741 (treat ref-to-raw cast like a reborrow: do a special kind of retag)

r? @ghost

bors added a commit that referenced this pull request Dec 16, 2018

Auto merge of #56875 - Centril:rollup, r=Centril
Rollup of 20 pull requests

Successful merges:

 - #53506 (Documentation for impl From for AtomicBool and other Atomic types)
 - #56343 (Remove not used mod)
 - #56439 (Clearer error message for dead assign)
 - #56640 (Add FreeBSD unsigned char platforms to std::os::raw)
 - #56648 (Fix BTreeMap UB)
 - #56672 (Document time of back operations of a Linked List)
 - #56706 (Make `const unsafe fn` bodies `unsafe`)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56761 (Suggest using `.display()` when trying to print a `Path`)
 - #56781 (Update LLVM submodule)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)
 - #56790 (Make RValue::Discriminant a normal Shallow read)
 - #56793 (rustdoc: look for comments when scraping attributes/crates from doctests)
 - #56826 (rustc: Add the `cmpxchg16b` target feature on x86/x86_64)
 - #56832 (std: Use `rustc_demangle` from crates.io)
 - #56844 (Improve CSS rule)
 - #56850 (Fixed issue with using `Self` ctor in typedefs)
 - #56855 (Remove u8 cttz hack)
 - #56857 (Fix a small mistake regarding NaNs in a deprecation message)
 - #56858 (Fix doc of `std::fs::canonicalize`)

Failed merges:

 - #56741 (treat ref-to-raw cast like a reborrow: do a special kind of retag)

r? @ghost

@bors bors merged commit ceee7f3 into rust-lang:master Dec 16, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@alexcrichton alexcrichton deleted the alexcrichton:simd_select_bitmask branch Dec 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment