Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot convert from f16 to i32 when targeting loongarch64 #21336

Closed
nektro opened this issue Sep 7, 2024 · 7 comments
Closed

cannot convert from f16 to i32 when targeting loongarch64 #21336

nektro opened this issue Sep 7, 2024 · 7 comments
Labels
arch-loongarch 32-bit and 64-bit LoongArch backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior upstream An issue with a third party project that Zig uses.
Milestone

Comments

@nektro
Copy link
Contributor

nektro commented Sep 7, 2024

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

@nektro nektro added the bug Observed behavior contradicts documented or intended behavior label Sep 7, 2024
@nektro
Copy link
Contributor Author

nektro commented Sep 7, 2024

can confirm this also affects 0.14.0-dev.1504+5f3d9e0b7

@alexrp
Copy link
Member

alexrp commented Sep 7, 2024

llvm/llvm-project#93894

@nektro
Copy link
Contributor Author

nektro commented Sep 7, 2024

nice, llvm/llvm-project@d075b7b made it into llvm 19

@alexrp
Copy link
Member

alexrp commented Sep 7, 2024

Now for the not-so-nice news: ziglang/zig-bootstrap#164 (comment)

@yxd-ym
Copy link
Contributor

yxd-ym commented Sep 8, 2024

ziglang/zig-bootstrap#164 (comment)

managed to pass this test with zig bootstrapped for loongarch64-linux-musl in comment above.

yxd@derp ~/tmp/test_zig $ file ~/opt/zig/musl-19/zig
/home/yxd/opt/zig/musl-19/zig: ELF 64-bit LSB executable, LoongArch, version 1 (GNU/Linux), statically linked, stripped
yxd@derp ~/tmp/test_zig $ ~/opt/zig/musl-19/zig version
0.14.0-dev.1499+0006b56f4
yxd@derp ~/tmp/test_zig $ cat test.zig
const std = @import("std");

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

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

    try std.testing.expect(b == 42);
}
yxd@derp ~/tmp/test_zig $ ~/opt/zig/musl-19/zig test test.zig -target loongarch64-linux-musl
All 1 tests passed.

@andrewrk andrewrk added upstream An issue with a third party project that Zig uses. backend-llvm The LLVM backend outputs an LLVM IR Module. arch-loongarch 32-bit and 64-bit LoongArch labels Sep 8, 2024
@andrewrk andrewrk added this to the unplanned milestone Sep 8, 2024
@yxd-ym
Copy link
Contributor

yxd-ym commented Sep 9, 2024

Now try to fix this issue with

llvm/llvm-project#107791

@alexrp alexrp mentioned this issue Sep 18, 2024
7 tasks
@andrewrk
Copy link
Member

Fixed with the merge of LLVM 19 branch in c6ad452.

@andrewrk andrewrk modified the milestones: unplanned, 0.14.0 Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-loongarch 32-bit and 64-bit LoongArch backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants