Skip to content

Bounds check is not eliminated #356

Open
@SeeSpring

Description

@SeeSpring

I tried this code:
Godbolt

#![feature(portable_simd)]
use std::simd::*;
pub fn increment(idx: Simd<u32, 8>, arr: &mut [u32]) {
    assert!(
        (arr.len() >= u32::MAX as usize)
            || idx.simd_lt(Simd::splat(arr.len() as u32)).all()
    );
    idx.as_array().iter().for_each(|i| arr[*i as usize] += 1);
}

I expected to see this happen: Bounds checks are eliminated and there is the vpcmpltd instruction

Instead, this happened: Bounds checks are not eliminated and a vpmaxud and vpcmpeqd pair is used

Meta

RUSTC_BOOTSTRAP=1 rustc --version --verbose:

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions