digitalmars.D - Integer overflow checking
- Andrei Alexandrescu (1/1) Apr 12 2016 Interesting: http://blog.regehr.org/archives/1384 -- Andrei
- Walter Bright (14/15) Apr 13 2016 Curiously never mentioned is the following optimization:
- deadalnix (4/19) Apr 13 2016 It is clearly not as optimal, but still pretty good. The article
- deadalnix (4/31) Apr 13 2016 Also, just checked, on sandy bridge, the LEA has 3clock latency
- Walter Bright (3/6) Apr 13 2016 The size is larger, too (not so cache friendly). Integer arithmetic is s...
- deadalnix (3/12) Apr 13 2016 Maybe not everywhere, but some security related code and/or tool
Interesting: http://blog.regehr.org/archives/1384 -- Andrei
Apr 12 2016
On 4/12/2016 5:06 AM, Andrei Alexandrescu wrote:Interesting: http://blog.regehr.org/archives/1384 -- AndreiCuriously 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.
Apr 13 2016
On Wednesday, 13 April 2016 at 22:13:27 UTC, Walter Bright wrote:On 4/12/2016 5:06 AM, Andrei Alexandrescu wrote:It is clearly not as optimal, but still pretty good. The article doesn't pretend it all come for free, just that it comes for much cheaper than before.Interesting: http://blog.regehr.org/archives/1384 -- AndreiCuriously 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.
Apr 13 2016
On Thursday, 14 April 2016 at 02:55:01 UTC, deadalnix wrote:On Wednesday, 13 April 2016 at 22:13:27 UTC, Walter Bright wrote:Also, just checked, on sandy bridge, the LEA has 3clock latency (but start earlier in the pipeline) and the add 1, so it is not as bad as it looks (it is still bad).On 4/12/2016 5:06 AM, Andrei Alexandrescu wrote:It is clearly not as optimal, but still pretty good. The article doesn't pretend it all come for free, just that it comes for much cheaper than before.Interesting: http://blog.regehr.org/archives/1384 -- AndreiCuriously 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.
Apr 13 2016
On 4/13/2016 8:00 PM, deadalnix wrote:Also, just checked, on sandy bridge, the LEA has 3clock latency (but start earlier in the pipeline) and the add 1, so it is not as bad as it looks (it is still bad).The size is larger, too (not so cache friendly). Integer arithmetic is sort of the bread and butter of computer programs, how much slowdown will people accept?
Apr 13 2016
On Thursday, 14 April 2016 at 04:52:12 UTC, Walter Bright wrote:On 4/13/2016 8:00 PM, deadalnix wrote:Maybe not everywhere, but some security related code and/or tool like ubsan surely can benefit from this.Also, just checked, on sandy bridge, the LEA has 3clock latency (but start earlier in the pipeline) and the add 1, so it is not as bad as it looks (it is still bad).The size is larger, too (not so cache friendly). Integer arithmetic is sort of the bread and butter of computer programs, how much slowdown will people accept?
Apr 13 2016