Skip to content
New issue

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

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

Already on GitHub? # to your account

x86 backend compile bug: error(x86_64_encoder): no encoding found for: none vsubss xmm0 xmm0 r32 none #20955

Open
Saladiator opened this issue Aug 5, 2024 · 0 comments
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@Saladiator
Copy link

Zig Version

0.14.0-dev.839+a931bfada

Steps to Reproduce and Observed Behavior

Cannot compile this program:

const std = @import("std");

pub fn main() !void {
    const bug = Bug {
        .x = 100,
        .y = 200,
    };
    // does not work
    std.log.info("value: {d}", .{ bug.bug() });

    // calling a non-self fn works:
    //std.log.info("value: {d}", .{ no_bug(bug.x, bug.y) });
}

const Bug = struct {
    x: f32,
    y: ?f32,

    const Self = @This();

    fn bug(self: *const Self) f32 {
        return if (self.y) |y| self.x - y else 0.0;
    }    
};

fn no_bug(x: f32, y: ?f32) f32 {
    return if (y) |y_| x - y_ else 0.0;
}
zig run -fno-llvm -fno-lld src/main.zig

zig run -fno-llvm -fno-lld src/main.zig
error(x86_64_encoder): no encoding found for: none vsubss xmm0 xmm0 r32 none
src/main.zig:21:5: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
    fn bug(self: *const Self) f32 {
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expected Behavior

It should print -100 when calling bug.bug().

@Saladiator Saladiator added the bug Observed behavior contradicts documented or intended behavior label Aug 5, 2024
@Vexu Vexu added this to the 0.15.0 milestone Aug 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants