x64: fix bug in lowering optionals directly to immediate

This commit is contained in:
Jakub Konka 2022-03-02 17:40:37 +01:00
parent b0bb1583cb
commit 77072d1a17
2 changed files with 2 additions and 2 deletions

View File

@ -5688,7 +5688,7 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {
.val = typed_value.val,
});
} else if (typed_value.ty.abiSize(self.target.*) == 1) {
return MCValue{ .immediate = @boolToInt(typed_value.val.isNull()) };
return MCValue{ .immediate = @boolToInt(!typed_value.val.isNull()) };
}
},
.Enum => {

View File

@ -179,7 +179,7 @@ test "@floatCast comptime_int and comptime_float" {
test "coerce undefined to optional" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try expect(MakeType(void).getNull() == null);
try expect(MakeType(void).getNonNull() != null);