mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
stage2 x86_64: fix comptime integer multiplication when rhs=0
Co-authored-by: joachimschmidt557 <joachim.schmidt557@outlook.com>
This commit is contained in:
parent
c4b83ea021
commit
613f39eb62
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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user