Integer overflow checking
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 13 15:13:27 PDT 2016
On 4/12/2016 5:06 AM, Andrei Alexandrescu wrote:
> Interesting: http://blog.regehr.org/archives/1384 -- Andrei
Curiously never mentioned is the following optimization:
return a+b*2+27;
becomes:
LEA EAX,27[ESI][EDI*2]
To overflow check:
ADD EDI,EDI
JO overflow
ADD EDI,27
JO overflow
MOV EAX,ESI
ADD EAX,EDI
JO overflow
I don't see efficiency there, even with the JO's being free.
More information about the Digitalmars-d
mailing list