diff options
| author | 2026-04-09 14:04:45 +0200 | |
|---|---|---|
| committer | 2026-04-09 14:05:31 +0200 | |
| commit | 3dd91560a2dca691953a5691e96787adeeb509d5 (patch) | |
| tree | 68f1f2b63436c6e92a00d665b850485f6990e490 | |
| parent | 7355aa3e9e88b7236fc86226b50ce820c7ff5220 (diff) | |
mkintcon: bugfix clamp i32 to i32 range
| -rw-r--r-- | src/ir.c | 6 | ||||
| -rw-r--r-- | src/ir_fold.c | 2 |
2 files changed, 5 insertions, 3 deletions
@@ -136,12 +136,14 @@ mkirtype(Type t) Ref mkintcon(enum irclass k, s64int i) { + if (cls2siz[k] == 4) { /* check upper half is zero or -1 */ + assert(in_range((i >> 32) + 1, 0, 1)); + i = (int)i; + } if (i < 1l << 28 && i >= -(1l << 28)) { return mkref(RICON, i); } else { IRCon con = { .cls = k, .i = i }; - if (cls2siz[k] == 4) /* check upper half is zero or -1 */ - assert(in_range((i >> 32) + 1, 0, 1)); return newxcon(&con); } } diff --git a/src/ir_fold.c b/src/ir_fold.c index 37edbbc..fcfe88b 100644 --- a/src/ir_fold.c +++ b/src/ir_fold.c @@ -67,7 +67,7 @@ foldint(enum op op, enum irclass k, Ref lr, Ref rr) case Ougte: x = l.u >= r.u; break; default: assert(0); } - if (cls2siz[k] < 8) x = (int)x; + if (!w) x = (int)x; return mkintcon(k, x); } |