stage2 x86_64: fix comptime integer multiplication when rhs=0

Co-authored-by: joachimschmidt557 <joachim.schmidt557@outlook.com>
This commit is contained in:
gracefu
2021-04-10 14:01:09 +08:00
parent c4b83ea021
commit 613f39eb62

View File

@@ -3864,10 +3864,15 @@ fn analyzeArithmetic(
// incase rhs is 0, simply return lhs without doing any calculations
// TODO Once division is implemented we should throw an error when dividing by 0.
if (rhs_val.compareWithZero(.eq)) {
return sema.mod.constInst(sema.arena, src, .{
.ty = scalar_type,
.val = lhs_val,
});
switch (zir_tag) {
.add, .addwrap, .sub, .subwrap => {
return sema.mod.constInst(sema.arena, src, .{
.ty = scalar_type,
.val = lhs_val,
});
},
else => {},
}
}
const value = switch (zir_tag) {