authorgravatar for 81774659+gracefuu@users.noreply.github.comgracefu <81774659+gracefuu@users.noreply.github.com> 2021-04-10 14:01:09+08:00
committergravatar for 81774659+gracefuu@users.noreply.github.comgracefu <81774659+gracefuu@users.noreply.github.com> 2021-04-16 15:21:17+08:00
log613f39eb622d341d036ef418b19778d1f04d5a47
tree6218de38f6206c0f3d278fdcc975001fdc0e9a39
parentc4b83ea02102611a85f75b189f0803d9b6a335c2
signaturelock-open Commit is signed but in an unrecognized format.

stage2 x86_64: fix comptime integer multiplication when rhs=0

Co-authored-by: joachimschmidt557 <joachim.schmidt557@outlook.com>

1 files changed, 9 insertions(+), 4 deletions(-)

src/Sema.zig+9-4
......@@ -3864,10 +3864,15 @@ fn analyzeArithmetic(
38643864 // incase rhs is 0, simply return lhs without doing any calculations
38653865 // TODO Once division is implemented we should throw an error when dividing by 0.
38663866 if (rhs_val.compareWithZero(.eq)) {
3867 return sema.mod.constInst(sema.arena, src, .{
3868 .ty = scalar_type,
3869 .val = lhs_val,
3870 });
3867 switch (zir_tag) {
3868 .add, .addwrap, .sub, .subwrap => {
3869 return sema.mod.constInst(sema.arena, src, .{
3870 .ty = scalar_type,
3871 .val = lhs_val,
3872 });
3873 },
3874 else => {},
3875 }
38713876 }
38723877
38733878 const value = switch (zir_tag) {