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

Comparing vector with optional vector causes LLVM ERROR: Cannot emit physreg copy instruction. #15022

Open
IntegratedQuantum opened this issue Mar 20, 2023 · 1 comment
Labels
backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@IntegratedQuantum
Copy link
Contributor

Zig Version

0.11.0-dev.1913+95f6a5935

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() void {
	const Vec2f = @Vector(2, f32);
	var a: ?Vec2f = .{0, 1};
	var b: Vec2f = .{0, 1};
	if(a == b) {
		std.log.info("Worked", .{});
	}
}

This code creates the following error:

$ zig run test.zig
LLVM Emit Object... LLVM ERROR: Cannot emit physreg copy instruction
Aborted (core dumped)

The first problem here is the missing zig compiler error.
Normally if a was not optional this code would cause a compiler error because vector comparisons produce bool vectors.

If I adapt the code to correctly @reduce the bool vector this happens:

const std = @import("std");

pub fn main() void {
	const Vec2f = @Vector(2, f32);
	var a: ?Vec2f = .{0, 1};
	var b: Vec2f = .{0, 1};
	if(@reduce(.And, a == b)) {
		std.log.info("Worked", .{});
	}
}

output:

$ zig run test.zig
test.zig:7:21: error: expected vector, found 'bool'
 if(@reduce(.And, a == b)) {
                  ~~^~~~

Expected Behavior

  • The comparison of vector and optional vectors should return a vector of bool (or cause a compiler error if that feature isn't supported).
  • It should not produce an llvm error.
@IntegratedQuantum IntegratedQuantum added the bug Observed behavior contradicts documented or intended behavior label Mar 20, 2023
@nektro
Copy link
Contributor

nektro commented Mar 20, 2023

related #12609

@Vexu Vexu added this to the 0.12.0 milestone Mar 20, 2023
@Vexu Vexu added the backend-llvm The LLVM backend outputs an LLVM IR Module. label Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants