AstGen: optimize ZIR for -1 literal

This commit is contained in:
mlugg 2024-03-01 06:01:53 +00:00
parent 408a08708f
commit eefa60e376
No known key found for this signature in database
GPG Key ID: 58978E823BDE3EF9

View File

@ -8458,7 +8458,14 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
try astgen.errNoteTok(num_token, "use '-0.0' for a floating-point signed zero", .{}),
},
),
1 => .one,
1 => {
// Handle the negation here!
const result: Zir.Inst.Ref = switch (sign) {
.positive => .one,
.negative => .negative_one,
};
return rvalue(gz, ri, result, source_node);
},
else => try gz.addInt(num),
},
.big_int => |base| big: {