zig
zig copied to clipboard
x86_64 regression: `@bitCast` to bool vectors produces incorrect results
Zig Version
0.16.0-dev.1415+db622f14c (worked in 0.15.2)
Steps to Reproduce and Observed Behavior
Run the following Zig code that bitcasts a u3 to a bool vector:
const std = @import("std");
pub fn main() !void {
var value: u3 = 7;
_ = &value;
std.log.err("{any}", .{@as(@Vector(3, bool), @bitCast(value))});
}
Observe how it produces false in newer versions with the x86_64 backend:
$ zig-debug run test.zig -fno-llvm
error: { false, false, false }
Expected Behavior
It should return true since all bits are set, this works in the llvm backend as well as the 0.15.2 x86_64 backend:
$ zig-debug run test.zig -fllvm
error: { true, true, true }
$ ~/Downloads/zig-x86_64-linux-0.15.2/zig run test.zig -fno-llvm
error: { true, true, true }
Note: it works if value is const instead of var. Also the same behavior occurs when bitcasting to a vector of u1 instead of bool
I think this is a duplicate of #24179
Not a duplicate, sounds like a real regression. This might be my fault (I may have broken some Legalize logic)