stage2 x86_64: fix comptime integer multiplication when rhs=0
Co-authored-by: joachimschmidt557 <joachim.schmidt557@outlook.com>
This commit is contained in:
13
src/Sema.zig
13
src/Sema.zig
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user