Skip to content

WASM+simd128 codegen of a.simd_eq(Simd::splat(b)).any() deteriorates as width increases #122623

Open
@alion02

Description

@alion02

The compiler lowers the following code to a 200+ instruction long scalar sequence on WASM+simd128:

#![feature(portable_simd)]
use core::simd::prelude::*;

fn f(a: u16x32, b: u16) -> bool {
    a.simd_eq(Simd::splat(b)).any()
}

The 256-bit wide version could also arguably use some work (for example could be compiled like this), but it's not catastrophically heavy and I don't really have any benchmarks to claim that it's slow.

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (c67326b06 2024-03-15)
binary: rustc
commit-hash: c67326b063bd27ed04f306ba2e372cd92e0a8751
commit-date: 2024-03-15
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0
Compiler returned: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-SIMDArea: SIMD (Single Instruction Multiple Data)A-codegenArea: Code generationC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-heavyIssue: Problems and improvements with respect to binary size of generated code.I-slowIssue: Problems and improvements with respect to performance of generated code.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/PG-portable-simdProject group: Portable SIMD (https://github.com/rust-lang/project-portable-simd)S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issuerequires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions