authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-01 06:01:53+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-01 06:01:53+00:00
logeefa60e376ba44e163a501143ff44dde445b4bfe
treecf4e1820c2c0cde161ac47fa7be6af5bc8838332
parent408a08708fbb0abe03bfeaa835666a72d79c843d
signaturelock-open Commit is signed but in an unrecognized format.

AstGen: optimize ZIR for `-1` literal


1 files changed, 8 insertions(+), 1 deletions(-)

lib/std/zig/AstGen.zig+8-1
......@@ -8458,7 +8458,14 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
84588458 try astgen.errNoteTok(num_token, "use '-0.0' for a floating-point signed zero", .{}),
84598459 },
84608460 ),
8461 1 => .one,
8461 1 => {
8462 // Handle the negation here!
8463 const result: Zir.Inst.Ref = switch (sign) {
8464 .positive => .one,
8465 .negative => .negative_one,
8466 };
8467 return rvalue(gz, ri, result, source_node);
8468 },
84628469 else => try gz.addInt(num),
84638470 },
84648471 .big_int => |base| big: {