aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-30 17:48:24 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-07-30 17:48:24 -0700
commit1f95c50d9a0c4c057780d387d57ac2ac40df1720 (patch)
treebf3f4560a5264f11902760dcb4ebf638b4f2e6b8 /src/codegen.zig
parent6e78c007dff96de98c44c52da890cdae3d6e1389 (diff)
downloadzig-1f95c50d9a0c4c057780d387d57ac2ac40df1720.tar.gz
zig-1f95c50d9a0c4c057780d387d57ac2ac40df1720.zip
codegen: cmp lowering treats bools the same as unsigned int
fixes a crash when lowering `a == b` and they are of type bool. I'm not worried about floats; I think we will probably add separate AIR instructions for floats.
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index bc3ff6257c..77672e82b0 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -2889,10 +2889,9 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
const src_mcv = try self.limitImmediateType(bin_op.rhs, i32);
try self.genX8664BinMathCode(Type.initTag(.bool), dst_mcv, src_mcv, 7, 0x38);
- const info = ty.intInfo(self.target.*);
- break :result switch (info.signedness) {
- .signed => MCValue{ .compare_flags_signed = op },
- .unsigned => MCValue{ .compare_flags_unsigned = op },
+ break :result switch (ty.isSignedInt()) {
+ true => MCValue{ .compare_flags_signed = op },
+ false => MCValue{ .compare_flags_unsigned = op },
};
},
.arm, .armeb => result: {
@@ -2934,10 +2933,9 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
// The destination register is not present in the cmp instruction
try self.genArmBinOpCode(undefined, lhs_mcv, rhs_mcv, false, .cmp_eq);
- const info = ty.intInfo(self.target.*);
- break :result switch (info.signedness) {
- .signed => MCValue{ .compare_flags_signed = op },
- .unsigned => MCValue{ .compare_flags_unsigned = op },
+ break :result switch (ty.isSignedInt()) {
+ true => MCValue{ .compare_flags_signed = op },
+ false => MCValue{ .compare_flags_unsigned = op },
};
},
else => return self.fail("TODO implement cmp for {}", .{self.target.cpu.arch}),