www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5364] New: optimizer kills high dword of -1

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364

           Summary: optimizer kills high dword of -1
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ellery-newcomer utulsa.edu



21:53:58 PST ---
dmd 2.050.

the code:

import std.stdio;
long b(long bmax){
    if(true){
    }
    if(bmax >= 0) bmax = -1;
    return bmax;
}

void main(){
    writeln(b(0));
}


the compilation:

dmd -O -inline test.d

the result:

4294967295

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



Works on Windows. (Tried 2.020, 2.030, 2.040, 2.049, 2.050, 2.051, also tried
-release).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
           Severity|normal                      |critical


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 30 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364




I can't reproduce this on Linux64 either, with the DMD from git master.
Unless somebody can reproduce this, it should be closed as WORKSFORME.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 01 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364




05:52:39 PDT ---
I am still seeing this behavior on DMD32 2.054, Fedora 14 64 bit. I don't have
internet access at home, so I can't test against DMD from git master.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 03 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364




19:19:25 PDT ---
just built dmd from github, and I am seeing this behavior there, too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364


Ellery Newcomer <ellery-newcomer utulsa.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|Other                       |x86



16:52:49 PDT ---
FWIW, just tested dmd 2.055 against this issue - 32 bit version has it, 64 bit
version doesn't.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 24 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364




Could you please post the disassembly of main() and b() when compiled with -O
-inline?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 26 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364




08:59:08 PDT ---
the compile:

~/Downloads/dmd2/linux/bin32/dmd pest -inline -O

the assembly dump:



08085344 <_D4pest1bFlZl>:
 8085344:       55                      push   ebp
 8085345:       8b ec                   mov    ebp,esp
 8085347:       8b 4d 0c                mov    ecx,DWORD PTR [ebp+0xc]
 808534a:       8b 44 24 08             mov    eax,DWORD PTR [esp+0x8]
 808534e:       85 c9                   test   ecx,ecx
 8085350:       7c 0d                   jl     808535f <_D4pest1bFlZl+0x1b>
 8085352:       7f 04                   jg     8085358 <_D4pest1bFlZl+0x14>
 8085354:       85 c0                   test   eax,eax
 8085356:       72 07                   jb     808535f <_D4pest1bFlZl+0x1b>
 8085358:       b8 ff ff ff ff          mov    eax,0xffffffff
 808535d:       31 c9                   xor    ecx,ecx
 808535f:       5d                      pop    ebp
 8085360:       8b d1                   mov    edx,ecx
 8085362:       c2 08 00                ret    0x8
 8085365:       90                      nop
 8085366:       90                      nop
 8085367:       90                      nop

08085368 <_Dmain>:
 8085368:       55                      push   ebp
 8085369:       8b ec                   mov    ebp,esp
 808536b:       6a 00                   push   0x0
 808536d:       6a 00                   push   0x0
 808536f:       e8 d0 ff ff ff          call   8085344 <_D4pest1bFlZl>
 8085374:       52                      push   edx
 8085375:       50                      push   eax
 8085376:       b8 84 67 0c 08          mov    eax,0x80c6784
 808537b:       6a 0a                   push   0xa
 808537d:       e8 22 00 00 00          call   80853a4
<_D3std5stdio4File14__T5writeTlTaZ5writeMFlaZv>
 8085382:       31 c0                   xor    eax,eax
 8085384:       5d                      pop    ebp
 8085385:       c3                      ret
 8085386:       90                      nop
 8085387:       90                      nop

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 26 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364




Here's what it does on 32-bit Windows. The commented line is where the
difference is.

            mov     ECX,8[ESP]
            mov     EAX,4[ESP]
            test    ECX,ECX
            jl      Lsecond
            jg      Lfirst
            test    EAX,EAX
            jb      Lsecond
Lfirst:     mov     EAX,0xFFFFFFFF
            mov     ECX,EAX    // xor ECX, ECX on failing case
Lsecond:    mov     EDX,ECX
            ret     8

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



21:12:36 PST ---
I can reproduce the problem on Linux.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED



00:57:46 PST ---
https://github.com/D-Programming-Language/dmd/commit/b1a31e2e9f35e523777467ae74eebfc99a3bb193

https://github.com/D-Programming-Language/dmd/commit/bc95288b4fb56166edc8c066eca1e17d97446f2e

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5364


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code klickverbot.at



---
*** Issue 6537 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2011