diff options
| -rw-r--r-- | ir/builder.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ir/builder.c b/ir/builder.c index 951c8f4..1348fe1 100644 --- a/ir/builder.c +++ b/ir/builder.c @@ -14,10 +14,11 @@ irbinop(struct function *fn, enum op op, enum irclass k, union ref l, union ref switch (op) { case Oadd: if (l.bits == ZEROREF.bits) return r; /* 0 + x ==> x */ - /* fallthru */ + if (r.bits == ZEROREF.bits) return l; /* x + 0 ==> x */ + break; case Osub: if (r.bits == ZEROREF.bits) return l; /* x - 0 ==> x */ - if (kisint(k) && l.bits == r.bits) return ZEROREF; /* x - 0 ==> x */ + if (kisint(k) && l.bits == r.bits) return ZEROREF; /* x - x ==> 0 */ break; case Omul: if (isnumcon(l)) rswap(l, r); /* put const in rhs */ |