Skip to content

cannot convert from f16 to i32 when targeting loongarch64 #21336

Closed
@nektro

Description

@nektro

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

const std = @import("std");

test {
    var a: f16 = 42.0;
    _ = &a;

    var b: i32 = @intFromFloat(a);
    _ = &b;

    try std.testing.expect(b == 42);
}
$ zig test test.zig -target loongarch64-linux-musl
LLVM ERROR: Cannot select: 0x7fb49a509b20: i64 = fp_to_fp16 0x7fb49956ba80
  0x7fb49956ba80: f32,ch = CopyFromReg 0x7fb4999973e0, Register:f32 %11
    0x7fb49956f010: f32 = Register %11
In function: __fixhfsi
Aborted (core dumped)

Expected Behavior

all 1 tests passed

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-loongarch32-bit and 64-bit LoongArchbackend-llvmThe LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorupstreamAn issue with a third party project that Zig uses.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions