Skip to content

Bad codegen for widen followed by ARM vdupq_n_* #137407

Closed

Description

@CatsAreFluffy

Code

I tried this code:

use std::arch::aarch64::*;

#[no_mangle]
pub unsafe fn half_dup(x: u16) -> uint16x8_t {
    vaddq_u16(vreinterpretq_u16_u32(vdupq_n_u32(x as u32)), vdupq_n_u16(1))
}

I expected to see this happen: The compiled output would use the dup instruction

Instead, this happened: The compiled output uses a bunch of movs instead

Godbolt

Version it worked on

It most recently worked on: Rust 1.81.0

Version with regression

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1

and

rustc 1.87.0-nightly (f280acf4c 2025-02-19)
binary: rustc
commit-hash: f280acf4c743806abbbbcfe65050ac52ec4bdec0
commit-date: 2025-02-19
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Activity

  1. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 22, 2025
  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    on Feb 22, 2025
  3. jieyouxu commented on Feb 22, 2025

    @jieyouxu
  4. nikic commented on Feb 22, 2025

    @nikic
    Contributor

    @jieyouxu Rust 1.82 would be the LLVM 19 upgrade.

  5. added
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing such
    and removed
    regression-untriagedUntriaged performance or correctness regression.
    C-bugCategory: This is a bug.
    on Feb 22, 2025
  6. jieyouxu commented on Feb 22, 2025

    @jieyouxu
    Member

    @jieyouxu Rust 1.82 would be the LLVM 19 upgrade.

    Yeah sorry somehow I didn't notice the 1.82

  7. hkratz commented on Feb 22, 2025

    @hkratz
    Contributor

    @rustbot label +A-SIMD +O-aarch64

  8. added
    A-SIMDArea: SIMD (Single Instruction Multiple Data)
    on Feb 22, 2025
  9. 9 remaining items

  10. removed
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    on Mar 25, 2025
  11. added a commit that references this issue on Jan 24, 2026
  12. added 4 commits that reference this issue on Jan 24, 2026
  13. added a commit that references this issue on Jan 24, 2026
  14. added a commit that references this issue on Jan 25, 2026
  15. folkertdev commented on Jan 27, 2026

    @folkertdev
    Contributor

    This issue was resolved by

    and now produces the expected:

    half_dup:
    	movi v0.8h, #1
    	and w9, w0, #0xffff
    	dup v1.4s, w9
    	add v0.8h, v1.8h, v0.8h
    	str q0, [x8]
    	ret
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-SIMDArea: SIMD (Single Instruction Multiple Data)C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchO-AArch64Armv8-A or later processors in AArch64 modeP-mediumMedium priorityS-has-bisectionStatus: A bisection has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions