From e8d8baac2db4efcb141caf4ab5e5605a162fefda Mon Sep 17 00:00:00 2001 From: Carl Friedrich Bolz-Tereick Date: Wed, 29 Apr 2020 21:44:47 +0200 Subject: add a comment about something that I have to re-learn every time I read this code --- rpython/jit/metainterp/optimizeopt/intbounds.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'rpython') diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py index c87d545f3d..a9445a5f8e 100644 --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -155,6 +155,12 @@ class OptIntBounds(Optimization): b2 = self.getintbound(op.getarg(1)) r = self.getintbound(op) b = b1.add_bound(b2) + # NB: the result only gets its bound updated if b has an upper and a + # lower bound. This is important, to do the right thing in the presence + # of overflow. Example: + # y = x + 1 where x >= 0 + # here it's tempting to give a bound of y >= 1, but that would be + # wrong, due to wraparound if b.bounded(): r.intersect(b) -- cgit v1.2.3-65-gdbad