Skip to content

Const-generic bounds should allow simple casts #84526

Closed
@aloucks

Description

@aloucks

The as_usize wrapper function in the example below shouldn't be required.

@oli-obk
#83278 (comment)

#![feature(const_generics)]
#![feature(const_evaluatable_checked)]

use std::arch::x86_64::*;

pub const fn _MM_SHUFFLE(fp3: u32, fp2: u32, fp1: u32, fp0: u32) -> i32 {
    ((fp3 << 6) | (fp2 << 4) | (fp1 << 2) | fp0) as i32
}

pub const fn as_usize(a: i32) -> usize {
    a as usize
}

pub fn swizzle<const X: u32, const Y: u32, const Z: u32, const W: u32>(v: __m128) -> __m128
where [(); as_usize(_MM_SHUFFLE(W, Z, Y, X))]:
{
    unsafe {
        _mm_shuffle_ps(v, v, _MM_SHUFFLE(W, Z, Y, X))
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.F-generic_const_exprs`#![feature(generic_const_exprs)]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions