Skip to content

std.fmt.parseFloat fails to encode instruction using x86_64 backed on unsafe release modes #22877

@sno2

Description

@sno2

Zig Version

0.14.0-dev.3213+53216d2f2

Steps to Reproduce and Observed Behavior

I found this while trying to build https://github.com/ziglang/translate-c without llvm/lld. This most likely regressed from #22873, as I could compile translate-c yesterday without llvm/lld.

Create the following test.zig file:

const std = @import("std");

test {
    // This works for f16, f32, and f64.
    // Both f80 and f128 fail to encode, though.
    _ = try std.fmt.parseFloat(f80, "1.0");
    _ = try std.fmt.parseFloat(f128, "1.0");
}

Now, test the executable in an unsafe release mode (ReleaseFast or ReleaseSmall):

$ zig test test.zig -fno-llvm -fno-lld -OReleaseSmall
error(x86_64_encoder): no encoding found for: none mul ymm none none none
/home/sno2/projects/zig/lib/std/fmt/parse_float/decimal.zig:186:13: error: emit MIR failed: InvalidInstruction (Zig compiler bug)
        pub fn rightShift(self: *Self, shift: usize) void {
        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ zig test test.zig -fno-llvm -fno-lld -OReleaseSmall
error(x86_64_encoder): no encoding found for: none mul ymm none none none
/home/sno2/projects/zig/lib/std/fmt/parse_float/decimal.zig:186:13: error: emit MIR failed: InvalidInstruction (Zig compiler bug)
        pub fn rightShift(self: *Self, shift: usize) void {
        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks

Expected Behavior

The test should run and pass like when in Debug mode:

$ zig test test.zig -fno-llvm -fno-lld
All 1 tests passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions