{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/362","repository_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd","labels_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/362/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/362/comments","events_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/362/events","html_url":"https://github.com/rust-lang-nursery/stdsimd/issues/362","id":303762582,"number":362,"title":"Boolean vectors should use hand-tuned any() and all()","user":{"login":"hsivonen","id":478856,"avatar_url":"https://avatars1.githubusercontent.com/u/478856?v=4","gravatar_id":"","url":"https://api.github.com/users/hsivonen","html_url":"https://github.com/hsivonen","followers_url":"https://api.github.com/users/hsivonen/followers","following_url":"https://api.github.com/users/hsivonen/following{/other_user}","gists_url":"https://api.github.com/users/hsivonen/gists{/gist_id}","starred_url":"https://api.github.com/users/hsivonen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hsivonen/subscriptions","organizations_url":"https://api.github.com/users/hsivonen/orgs","repos_url":"https://api.github.com/users/hsivonen/repos","events_url":"https://api.github.com/users/hsivonen/events{/privacy}","received_events_url":"https://api.github.com/users/hsivonen/received_events","type":"User","site_admin":false},"labels":[{"id":819658219,"url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/labels/A-portable","name":"A-portable","color":"bfdadc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2018-03-09T08:33:52Z","updated_at":"2018-04-12T08:09:44Z","closed_at":null,"author_association":"NONE","body":"Thank you for adding portable SIMD and boolean vectors!\r\n\r\nIn `stdsimd`, `any()` and `all()` are based LLVM cross-ISA on bitwise reductions across the vector, so these operations fail to use the type system information that is the reason for their existence: The information that all the bits of each lane are the same. I.e. in `b8x16`, each lane is either 0 or 0xFF.\r\n\r\nThis means that looking at all the bits is unnecessary, since for each lane, examining any one bit is sufficient. In the SSE2 case, `_mm_movemask_epi8` takes one bit from each lane of a `u8x16`. It's what the `simd` crate uses.\r\n\r\nI've uploaded a [demo crate](https://github.com/hsivonen/anyall) that exports uninlined versions of `any()` and `all()` on `u8x16` using both `simd` and `stdsimd`. The generated code for the `simd` crate versions is much simpler. Code generated using `stdsimd` should be as good.\r\n\r\n```asm\r\n    .text\r\n    .file   \"anyall0-66776763bbd7db1b14e447f414e2cf9a.rs\"\r\n    .section    .text.stdsimd_any_8x16,\"ax\",@progbits\r\n    .globl  stdsimd_any_8x16\r\n    .p2align    4, 0x90\r\n    .type   stdsimd_any_8x16,@function\r\nstdsimd_any_8x16:\r\n    .cfi_startproc\r\n    movdqa  (%rdi), %xmm0\r\n    pshufd  $78, %xmm0, %xmm1\r\n    por %xmm0, %xmm1\r\n    pshufd  $229, %xmm1, %xmm0\r\n    por %xmm1, %xmm0\r\n    movdqa  %xmm0, %xmm1\r\n    psrld   $16, %xmm1\r\n    por %xmm0, %xmm1\r\n    movdqa  %xmm1, %xmm0\r\n    psrlw   $8, %xmm0\r\n    por %xmm1, %xmm0\r\n    movd    %xmm0, %eax\r\n    testb   %al, %al\r\n    setne   %al\r\n    retq\r\n.Lfunc_end0:\r\n    .size   stdsimd_any_8x16, .Lfunc_end0-stdsimd_any_8x16\r\n    .cfi_endproc\r\n\r\n    .section    .text.stdsimd_all_8x16,\"ax\",@progbits\r\n    .globl  stdsimd_all_8x16\r\n    .p2align    4, 0x90\r\n    .type   stdsimd_all_8x16,@function\r\nstdsimd_all_8x16:\r\n    .cfi_startproc\r\n    movdqa  (%rdi), %xmm0\r\n    pshufd  $78, %xmm0, %xmm1\r\n    pand    %xmm0, %xmm1\r\n    pshufd  $229, %xmm1, %xmm0\r\n    pand    %xmm1, %xmm0\r\n    movdqa  %xmm0, %xmm1\r\n    psrld   $16, %xmm1\r\n    pand    %xmm0, %xmm1\r\n    movdqa  %xmm1, %xmm0\r\n    psrlw   $8, %xmm0\r\n    pand    %xmm1, %xmm0\r\n    movd    %xmm0, %eax\r\n    testb   %al, %al\r\n    setne   %al\r\n    retq\r\n.Lfunc_end1:\r\n    .size   stdsimd_all_8x16, .Lfunc_end1-stdsimd_all_8x16\r\n    .cfi_endproc\r\n\r\n    .section    .text.simd_any_8x16,\"ax\",@progbits\r\n    .globl  simd_any_8x16\r\n    .p2align    4, 0x90\r\n    .type   simd_any_8x16,@function\r\nsimd_any_8x16:\r\n    .cfi_startproc\r\n    movdqa  (%rdi), %xmm0\r\n    pmovmskb    %xmm0, %eax\r\n    testl   %eax, %eax\r\n    setne   %al\r\n    retq\r\n.Lfunc_end2:\r\n    .size   simd_any_8x16, .Lfunc_end2-simd_any_8x16\r\n    .cfi_endproc\r\n\r\n    .section    .text.simd_all_8x16,\"ax\",@progbits\r\n    .globl  simd_all_8x16\r\n    .p2align    4, 0x90\r\n    .type   simd_all_8x16,@function\r\nsimd_all_8x16:\r\n    .cfi_startproc\r\n    movdqa  (%rdi), %xmm0\r\n    pmovmskb    %xmm0, %eax\r\n    cmpl    $65535, %eax\r\n    sete    %al\r\n    retq\r\n.Lfunc_end3:\r\n    .size   simd_all_8x16, .Lfunc_end3-simd_all_8x16\r\n    .cfi_endproc\r\n\r\n\r\n    .section    \".note.GNU-stack\",\"\",@progbits\r\n```"},"comment":{"url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/comments/380716384","html_url":"https://github.com/rust-lang-nursery/stdsimd/issues/362#issuecomment-380716384","issue_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/362","id":380716384,"user":{"login":"hsivonen","id":478856,"avatar_url":"https://avatars1.githubusercontent.com/u/478856?v=4","gravatar_id":"","url":"https://api.github.com/users/hsivonen","html_url":"https://github.com/hsivonen","followers_url":"https://api.github.com/users/hsivonen/followers","following_url":"https://api.github.com/users/hsivonen/following{/other_user}","gists_url":"https://api.github.com/users/hsivonen/gists{/gist_id}","starred_url":"https://api.github.com/users/hsivonen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hsivonen/subscriptions","organizations_url":"https://api.github.com/users/hsivonen/orgs","repos_url":"https://api.github.com/users/hsivonen/repos","events_url":"https://api.github.com/users/hsivonen/events{/privacy}","received_events_url":"https://api.github.com/users/hsivonen/received_events","type":"User","site_admin":false},"created_at":"2018-04-12T08:09:44Z","updated_at":"2018-04-12T08:09:44Z","author_association":"NONE","body":"Thanks. I filed an [issue](https://github.com/rust-lang/rust/issues/49897) about NEON-enabled ARMv7 targets and I intend to try to write a PR for it now. (aarch64 should be fine already.)"}}
{"actor":{"display_login":"hsivonen"}}