Skip to content

x86 Various issues with extract_epiNN functions #867

Closed
@jethrogb

Description

@jethrogb

1. Inconsistent function signatures

The SSE versions have the following signatures:

pub unsafe fn _mm_extract_epi8(a: __m128i, imm8: i32) -> i32;
pub unsafe fn _mm_extract_epi16(a: __m128i, imm8: i32) -> i32;

But the AVX versions have the following:

pub unsafe fn _mm256_extract_epi8(a: __m256i, imm8: i32) -> i8;
pub unsafe fn _mm256_extract_epi16(a: __m256i, imm8: i32) -> i16;

Note the difference in return type. Since Intel specifies these all return int, it's not clear how this happened. I thought the function signatures are supposed to be machine-checked?

2. Incorrect sign extension

use core::arch::x86_64::*;

fn main() {
    println!("{:x}", unsafe{_mm_extract_epi16(_mm_set1_epi8(!0), 0)});
}

This prints: ffffffff. Intel specifies the upper 16 bits should be 0.

cc @AdrianCX

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions