From 821adf9e5c962c97e46f3a215c876bc10916e302 Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 21 Nov 2025 16:52:46 +0100 Subject: remove umul --- amd64/emit.c | 1 - amd64/isel.c | 5 ++--- c/c.c | 4 ++-- ir/builder.c | 2 +- ir/fold.c | 1 - ir/op.def | 1 - 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/amd64/emit.c b/amd64/emit.c index a7bf542..5a63a61 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -1041,7 +1041,6 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc break; case Omul: if (kisint(cls)) - case Oumul: Ximul(pcode, cls, reg2oper(ins->reg-1), ref2oper(ins->l), ref2oper(ins->r)); else Xmulf(pcode, cls, reg2oper(ins->reg-1), ref2oper(ins->r)); diff --git a/amd64/isel.c b/amd64/isel.c index b17e541..2ae9a92 100644 --- a/amd64/isel.c +++ b/amd64/isel.c @@ -15,7 +15,6 @@ static const uchar opflags[NOPER] = { [Oadd] = ZF|CLOBF, [Osub] = ZF|CLOBF, [Omul] = CLOBF, - [Oumul] = CLOBF, [Odiv] = CLOBF, [Oudiv] = CLOBF, [Orem] = CLOBF, @@ -457,7 +456,7 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi) } } /* fallthru */ - case Omul: case Oumul: + case Omul: case Oand: case Oxor: case Oior: /* commutative ops */ if (iscon(ins->l)) @@ -473,7 +472,7 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi) case Onot: ALU: if (!(op == Oadd && kisint(ins->cls))) /* 3-address add is lea */ - if (!(in_range(op, Omul, Oumul) && kisint(ins->cls) && isimm32(ins->r))) /* for (I)MUL r,r/m,imm */ + if (!(op == Omul && kisint(ins->cls) && isimm32(ins->r))) /* for (I)MUL r,r/m,imm */ ins->inplace = 1; if (iscon(ins->l)) { fixarg(&ins->l, ins, blk, curi); diff --git a/c/c.c b/c/c.c index cc82950..5708419 100644 --- a/c/c.c +++ b/c/c.c @@ -3255,7 +3255,7 @@ compileexpr(struct function *fn, const struct expr *ex, bool discard) case EADDROF: return expraddr(fn, sub); case EMUL: - op = isunsigned(ex->ty) ? Oumul : Omul; + op = Omul; goto BinArith; case EDIV: op = isunsigned(ex->ty) ? Oudiv : Odiv; @@ -3382,7 +3382,7 @@ compileexpr(struct function *fn, const struct expr *ex, bool discard) if (discard) return NOREF; return bitsiz ? narrow(fn, cls, sub[0].ty, q, bitsiz) : q; case ESETMUL: - op = isunsigned(ex->ty) ? Oumul : Omul; + op = Omul; goto Compound; case ESETDIV: op = isunsigned(ex->ty) ? Oudiv : Odiv; diff --git a/ir/builder.c b/ir/builder.c index 9c6a0ef..b177a39 100644 --- a/ir/builder.c +++ b/ir/builder.c @@ -18,7 +18,7 @@ irbinop(struct function *fn, enum op op, enum irclass k, union ref l, union ref case Osub: if (r.bits == ZEROREF.bits) return l; /* x +/- 0 ==> x */ break; - case Omul: case Oumul: + case Omul: if (isnumcon(l)) rswap(l, r); /* put const in rhs */ if (r.bits == ZEROREF.bits) /* x * 0 ==> 0 */ return ZEROREF; diff --git a/ir/fold.c b/ir/fold.c index 751583e..b45aa38 100644 --- a/ir/fold.c +++ b/ir/fold.c @@ -27,7 +27,6 @@ foldint(enum op op, enum irclass k, union ref lr, union ref rr) case Oadd: x = l.u + r.u; break; case Osub: x = l.u - r.u; break; case Omul: x = l.u * r.u; break; - case Oumul: x = l.u * r.u; break; case Odiv: x = w ? l.s / r.s : (int)l.s / (int)r.s; break; case Oudiv: x = w ? l.u / r.u : (uint)l.u / (uint)r.u; break; case Orem: x = w ? l.s % r.s : (int)l.s % (int)r.s; break; diff --git a/ir/op.def b/ir/op.def index b3d237c..947b1f0 100644 --- a/ir/op.def +++ b/ir/op.def @@ -23,7 +23,6 @@ _(extu32, 1) _(add, 2) _(sub, 2) _(mul, 2) -_(umul, 2) _(div, 2) _(udiv, 2) _(rem, 2) -- cgit v1.2.3