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

LLVM 14 regression: std.fmt.parseFloat gives wrong bit pattern for NaN on aarch64 #12027

Closed
andrewrk opened this issue Jul 6, 2022 · 2 comments · Fixed by #16535
Closed

LLVM 14 regression: std.fmt.parseFloat gives wrong bit pattern for NaN on aarch64 #12027

andrewrk opened this issue Jul 6, 2022 · 2 comments · Fixed by #16535
Labels
arch-aarch64 64-bit ARM backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. miscompilation The compiler reports success but produces semantically incorrect code. regression It worked in a previous version of Zig, but stopped working. upstream An issue with a third party project that Zig uses.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Jul 6, 2022

Zig Version: 0.10.0-dev.2896+fa40bddf2

Reproduce:

$ stage1/bin/zig test ../lib/std/std.zig -target aarch64-linux-none
Test [801/2198] fmt.parse_float.test "std-aarch64-linux-none-Debug-bare-multi-default f... expected 32257, found 31745
Test [801/2198] fmt.parse_float.test "std-aarch64-linux-none-Debug-bare-multi-default f... FAIL (TestExpectedEqual)
2118 passed; 79 skipped; 1 failed.
error: the following test command failed with exit code 1:
qemu-aarch64 /home/andy/dev/zig/zig-cache/o/554571ccb0691b6a5f1b1367cbe29186/test /home/andy/dev/zig/build-llvm14-debug/stage1/bin/zig
test...The following command exited with error code 1:
/home/andy/dev/zig/build-llvm14-debug/stage1/bin/zig test /home/andy/dev/zig/lib/std/std.zig --test-name-prefix std-aarch64-linux-none-Debug-bare-multi-default  --cache-dir /home/andy/dev/zig/zig-cache --global-cache-dir /home/andy/.cache/zig --name test -fno-single-threaded -target aarch64-linux-none -mcpu generic --test-cmd qemu-aarch64 --test-cmd-bin -I /home/andy/dev/zig/test -L /home/andy/local/llvm14-debug/lib -isystem /home/andy/local/llvm14-debug/include --zig-lib-dir /home/andy/dev/zig/lib --enable-cache 

Failing test case is:

try expectEqual(@bitCast(Z, try parseFloat(T, "nAn")), @bitCast(Z, std.math.nan(T)));

Next steps:

  1. Create LLVM IR test case
  2. use llvm-reduce to create reduction
  3. Check if bug is present on trunk
  4. File upstream bug report
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. upstream An issue with a third party project that Zig uses. arch-aarch64 64-bit ARM backend-llvm The LLVM backend outputs an LLVM IR Module. regression It worked in a previous version of Zig, but stopped working. labels Jul 6, 2022
@andrewrk andrewrk added this to the 0.11.0 milestone Jul 6, 2022
@andrewrk andrewrk added the miscompilation The compiler reports success but produces semantically incorrect code. label Jul 7, 2022
@topolarity
Copy link
Contributor

Not a direct reduction, but I found what appears to be a closely related failure:

noinline fn nan(comptime T: type) T {
    return comptime std.math.nan(T);
}

test {
    const nan_const = comptime @bitCast(u16, std.math.nan(f16));
    if (nan_const != @bitCast(u16, nan(f16))) unreachable;
}

This reproduces on LLVM 13 (including Zig 0.9.1 and latest master). Bug filed here: llvm/llvm-project#56454

wooster0 added a commit to wooster0/zig that referenced this issue Dec 7, 2022
wooster0 added a commit to wooster0/zig that referenced this issue Dec 7, 2022
wooster0 added a commit to wooster0/zig that referenced this issue Dec 7, 2022
wooster0 added a commit to wooster0/zig that referenced this issue Dec 7, 2022
wooster0 added a commit to wooster0/zig that referenced this issue Dec 8, 2022
wooster0 added a commit to wooster0/zig that referenced this issue Dec 8, 2022
wooster0 added a commit to wooster0/zig that referenced this issue Dec 9, 2022
kcbanner pushed a commit to kcbanner/zig that referenced this issue Dec 10, 2022
andrewrk added a commit that referenced this issue Dec 28, 2022
This reverts commit 3370d58.

This commit was done with an LLVM build that did not have assertions
enabled. There are LLVM assertions being triggered due to this commit.

Reopens #10627
Reopens #12013
Reopens #12027
@andrewrk
Copy link
Member Author

Reopened by 5ca1753

@andrewrk andrewrk reopened this Dec 28, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Jun 19, 2023
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Jul 22, 2023
matu3ba added a commit to matu3ba/zig that referenced this issue Jul 24, 2023
@andrewrk andrewrk modified the milestones: 0.11.0, 0.11.1 Jul 25, 2023
@andrewrk andrewrk modified the milestones: 0.11.1, 0.11.0 Jul 25, 2023
cactusbento pushed a commit to cactusbento/zig that referenced this issue Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-aarch64 64-bit ARM backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. miscompilation The compiler reports success but produces semantically incorrect code. regression It worked in a previous version of Zig, but stopped working. upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants