diff options
Diffstat (limited to 'fold.c')
-rw-r--r-- | fold.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fold.c b/fold.c index 019b739..521c911 100644 --- a/fold.c +++ b/fold.c @@ -371,15 +371,15 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) switch (op) { case Oadd: x = l.u + r.u; break; case Osub: x = l.u - r.u; break; - case Odiv: x = l.s / r.s; break; - case Orem: x = l.s % r.s; break; + case Odiv: x = w ? l.s / r.s : (int32_t)l.s / (int32_t)r.s; break; + case Orem: x = w ? l.s % r.s : (int32_t)l.s % (int32_t)r.s; break; case Oudiv: x = l.u / r.u; break; case Ourem: x = l.u % r.u; break; case Omul: x = l.u * r.u; break; case Oand: x = l.u & r.u; break; case Oor: x = l.u | r.u; break; case Oxor: x = l.u ^ r.u; break; - case Osar: x = l.s >> (r.u & 63); break; + case Osar: x = (w ? l.s : (int32_t)l.s) >> (r.u & 63); break; case Oshr: x = l.u >> (r.u & 63); break; case Oshl: x = l.u << (r.u & 63); break; case Oextsb: x = (int8_t)l.u; break; |