Jump to page: 1 2
Thread overview
[Issue 5364] New: optimizer kills high dword of -1
Dec 23, 2010
Ellery Newcomer
Dec 23, 2010
Don
Dec 31, 2010
Don
Aug 01, 2011
Don
Aug 03, 2011
Ellery Newcomer
Aug 12, 2011
Ellery Newcomer
Sep 24, 2011
Ellery Newcomer
Sep 26, 2011
Don
Sep 26, 2011
Ellery Newcomer
Oct 15, 2011
Don
Nov 18, 2011
Walter Bright
Nov 18, 2011
Walter Bright
Nov 18, 2011
Walter Bright
Nov 18, 2011
klickverbot
December 23, 2010
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


--- Comment #0 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2010-12-22 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: -------
December 23, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5364


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-12-22 23:46:32 PST ---
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: -------
December 31, 2010
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: -------
August 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5364



--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-08-01 03:59:14 PDT ---
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: -------
August 03, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5364



--- Comment #3 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2011-08-03 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: -------
August 12, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5364



--- Comment #4 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2011-08-11 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: -------
September 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5364


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

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


--- Comment #5 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2011-09-24 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: -------
September 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5364



--- Comment #6 from Don <clugdbug@yahoo.com.au> 2011-09-26 07:32:12 PDT ---
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: -------
September 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5364



--- Comment #7 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2011-09-26 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: -------
October 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5364



--- Comment #8 from Don <clugdbug@yahoo.com.au> 2011-10-15 16:03:33 PDT ---
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: -------
« First   ‹ Prev
1 2