On Wed, 2008-03-26 at 14:11 -0700, Chris Lattner wrote:> On Wed, 26 Mar 2008, Jonathan S. Shapiro wrote:
> >> Why not define an "add with overflow" intrinsic that
returns its value and
> >> overflow bit as an i1?
> >
> > Chris:
> >
> > I understand several simple ways to implement add with carry. Your
> > suggestion is one of them. What I'm trying to understand is how to
> > handle the conditional code issue generally.
>
> I'm suggesting basically:
>
> res,overflow = add_with_cary(a,b);
> if (overflow) goto somewhere
> use(res)
>
> -Chris
Yes. Sorry. I do see that that will work, and I had not intended to
sound ungrateful for your response. It is my nature, when I look at a
design problem, to try to consider the whole problem before implementing
some part. It may turn out here that there isn't really a "whole
problem" to consider. Even if there is, I agree that the shortest path
to solving my immediate problem is to do exactly as you suggest.
I guess my take is that when faced with an architectural question that
you eventually may have to address in full, quick fixes tend to accrete
that have to be undone when you get around to the general solution, and
these make implementing the general thing harder -- unless you have
thought it out in advance and the quick fixes are in line with the
eventual solution.
Now it may turn out that there isn't any "general thing" here at
all.
It's just that I'ld like to think that through before adopting what you
suggest.
shap