[Issue 16268] Wrong optimization in code with integer overflow

2020-08-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16268

Walter Bright  changed:

   What|Removed |Added

   Keywords||backend
 CC||bugzi...@digitalmars.com

--


[Issue 16268] Wrong optimization in code with integer overflow

2016-07-12 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16268

Lodovico Giaretta  changed:

   What|Removed |Added

 CC||lodov...@giaretart.net

--- Comment #1 from Lodovico Giaretta  ---
Looking at the generated assembly, it looks like, as a check x >= 0 is
performed before entering the loop, the compiler establishes that overflow will
not happen while condition i <= x holds (with x not negative).
Of course this is false for the edge case of x = typeof(x).max.

00  push   rbp
01  movrbp,rsp
04  push   rbx
05  push   r12
07  movr12,rdi
0a  xorebx,ebx ; i = 0
0c  test   r12b,r12b
0f  js 21  ; if x < 0 skip for loop
11  movsx  edi,bl
15  call  ; call writeln
1a  incbl  ; i++
1c  cmpbl,r12b
1f  jle11  ; if i <= x continue for loop
21  popr12
23  poprbx
24  poprbp
25  ret

--


[Issue 16268] Wrong optimization in code with integer overflow

2016-07-12 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16268

ag0ae...@gmail.com changed:

   What|Removed |Added

   Keywords||wrong-code
 CC||ag0ae...@gmail.com

--