Skip to content

Significantly worse codegen for SIMD shuffles after Rust 1.73.0 #129132

Open
@TDecking

Description

@TDecking

See https://godbolt.org/z/jKczKPMMe.

The code is the following:

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

#[no_mangle]
pub unsafe fn custom_shuffle(x: __m128i) -> __m128i {
    let mut tmp1 = _mm_unpacklo_epi8(x, _mm_setzero_si128());
    tmp1 = _mm_shuffle_epi32::<78>(tmp1);
    tmp1 = _mm_shufflelo_epi16::<27>(tmp1);
    tmp1 = _mm_shufflehi_epi16::<27>(tmp1);

    let mut tmp2 = _mm_unpackhi_epi8(x, _mm_setzero_si128());
    tmp2 = _mm_shuffle_epi32::<78>(tmp2);
    tmp2 = _mm_shufflelo_epi16::<27>(tmp2);
    tmp2 = _mm_shufflehi_epi16::<27>(tmp2);

    _mm_packus_epi16(tmp2, tmp1)
}

The regression happened between Rust 1.72.0 and Rust 1.73.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-slowIssue: Problems and improvements with respect to performance of generated code.P-mediumMedium priorityllvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesregression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions