aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2025-02-03 01:10:34 -0500
committerJacob Young <jacobly0@users.noreply.github.com>2025-02-06 16:14:53 -0500
commit39119088f968c36ec72ad0ebb69e02ce31b5a033 (patch)
tree58e96616a3198bb23f69989c1b9199eed6d26594 /src/Sema.zig
parentc58e60a042ec2a351a0d8953f602fc23763e3ecd (diff)
downloadzig-39119088f968c36ec72ad0ebb69e02ce31b5a033.tar.gz
zig-39119088f968c36ec72ad0ebb69e02ce31b5a033.zip
x86_64: rewrite vector `@truncate`
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index ad144bf013..3024ba1047 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -23751,23 +23751,27 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
@tagName(dest_info.signedness), operand_ty.fmt(pt),
});
}
- if (operand_info.bits < dest_info.bits) {
- const msg = msg: {
- const msg = try sema.errMsg(
- src,
- "destination type '{}' has more bits than source type '{}'",
- .{ dest_ty.fmt(pt), operand_ty.fmt(pt) },
- );
- errdefer msg.destroy(sema.gpa);
- try sema.errNote(src, msg, "destination type has {d} bits", .{
- dest_info.bits,
- });
- try sema.errNote(operand_src, msg, "operand type has {d} bits", .{
- operand_info.bits,
- });
- break :msg msg;
- };
- return sema.failWithOwnedErrorMsg(block, msg);
+ switch (std.math.order(dest_info.bits, operand_info.bits)) {
+ .gt => {
+ const msg = msg: {
+ const msg = try sema.errMsg(
+ src,
+ "destination type '{}' has more bits than source type '{}'",
+ .{ dest_ty.fmt(pt), operand_ty.fmt(pt) },
+ );
+ errdefer msg.destroy(sema.gpa);
+ try sema.errNote(src, msg, "destination type has {d} bits", .{
+ dest_info.bits,
+ });
+ try sema.errNote(operand_src, msg, "operand type has {d} bits", .{
+ operand_info.bits,
+ });
+ break :msg msg;
+ };
+ return sema.failWithOwnedErrorMsg(block, msg);
+ },
+ .eq => return operand,
+ .lt => {},
}
}