Skip to content

Keep LoongArch SIMD dependencies consistent with disabled floating-point features #792

Closed

Description

@LunaStev

Problem

LoongArch target resolution advertises disabled floating-point features while leaving LSX enabled. LLVM then re-enables the implied floating-point features and emits instructions the printed target configuration says are disabled. For example, --abi=lp64s reports -f,-d,+lsx,-lasx,+ual,-relax, but a double addition uses fadd.d.

The resolver checks D → F and LASX → LSX, but misses LSX → D. LLVM 21.1.8's feature definitions specify that dependency. Starting points: llvm/src/codegen/target.rs, llvm/src/codegen/arch/loongarch64.rs.

Reproduction

Executed at 4c3372157d8889fa8bbef0a7ccd2e72aab1c5c6c on Linux amd64 with LLVM 21.1.8 and the checkout-built compiler. Save as loong_float.wave:

export(c) fun add_double(left: f64, right: f64) -> f64 { return left + right; }
fun main() -> i32 { return 0; }
target/debug/wavec print target-spec --target loongarch64-unknown-linux-gnu --abi=lp64s --format=json
target/debug/wavec build loong_float.wave --target loongarch64-unknown-linux-gnu --abi=lp64s --emit=asm,ir -O2 --out-dir /tmp/loong-default
target/debug/wavec build loong_float.wave --target loongarch64-unknown-linux-gnu --abi=lp64s --features=-lsx,-lasx --emit=asm,ir -O2 --out-dir /tmp/loong-no-simd

The first assembly contains fadd.d; disabling LSX/LASX produces a call to __adddf3. The same difference occurs with --abi=lp64f, whose printed configuration contains +f,-d,+lsx.

Scope

Make default feature selection, explicit feature validation and printed target information agree with LLVM's effective dependency closure. Preserve the existing ABI contracts and valid lp64d SIMD configurations.

This is a feature-resolution defect, not evidence that a soft-float calling convention inherently forbids hardware FP instructions. Separate C-to-Wave scalar interoperability controls for lp64s/lp64f/lp64d all returned the correct result under QEMU. Do not change calling-convention rules based on this reproduction.

Difficulty: medium.

Completion criteria

  • lp64s/lp64f defaults no longer silently contradict their advertised F/D settings.
  • Explicit combinations involving F, D, LSX and LASX either resolve consistently or produce a useful diagnostic.
  • Cover target-spec output and generated assembly, with existing ABI interoperability controls retained.

Activity

  1. added
    bug
    help wanted
    cross-platform
    on Sep 26, 2026
  2. self-assigned this
    on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcross-platformhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions