Integer overflow and underflow semantics?

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 21 02:58:01 PDT 2014


"Marc Schütz" <schuetzm at gmx.net> wrote:
> On Sunday, 20 July 2014 at 11:09:45 UTC, Tobias Müller wrote:
>> "Marc Schütz" <schuetzm at gmx.net> wrote:
>>> On Saturday, 19 July 2014 at 19:49:24 UTC, Ola Fosheim Grøstad >> wrote:
>>>> On Saturday, 19 July 2014 at 08:34:39 UTC, Kagamin wrote:
>>>>> Can't it simply generate code as is? Seems wasteful to spend
>>>>>>> compilation time on this.
>>>>>>> Not if you want fast code, consider a template with:
>>>>>>> if (a.length+M < b.length+N) {}
>>>>>>> then you alias b = a in the template instantiation:
>>>>>>> if(a.length+M < a.length+N){}
>>>>>>> you want this reduced to:
>>>>>>> if (M<N){
>>>> }
>>>>>>> which can be resolved at compile time.
>>>>> Yes, but that is the optimizer's job. The front-end doesn't >> need to spend
>>> time on it, if the back-end then anyway does the same >> optimization again.
>> 
>> I don't think anyone has said that the frontend does that.
> 
> I do ;-) This is how I interpret Kagamin's post.

Hm I interpreted it the other way round, it's wasteful to spend time for
such optimizations, just.
But my english is probably not as good as yours.

Tobi


More information about the Digitalmars-d mailing list