public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: "omar beo" <omarbeo@hotmail.com>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: optimization/10772: Result differences between debug and optmize libs on linux; and with sol/nt on optimize mode
Date: Wed, 14 May 2003 15:16:00 -0000	[thread overview]
Message-ID: <20030514151601.9341.qmail@sources.redhat.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5122 bytes --]

The following reply was made to PR optimization/10772; it has been noted by GNATS.

From: "omar beo" <omarbeo@hotmail.com>
To: giovannibajo@libero.it, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, omarbeo@hotmail.com, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: optimization/10772: Result differences between debug and optmize libs on
 linux; and with sol/nt on optimize mode
Date: Wed, 14 May 2003 09:08:14 -0600

 Hi,
 This problem could be related to the Rounding as many suggested, but how 
 come I got different numbers between debug and optimize libs when I run on 
 linux?
 Why this code generates the same numbers on NT and Unix, but not on linux?
 
 Unfortunately, I wasn’t able to create an identical test case to the one i'm 
 currently testing, probably because this behavior only happened when you run 
 a large application and not just a small test case.
 But i included a simalr test case with a similar behavior.
 
 Could you look at the assembly code generated on debug and optimize mode, 
 and tell me if they are equivalent. Because they don't produce the same 
 numbers .
 
 Thank you.
 
 
 Here the C++ code:
 
 double this->factor;
 int this->GetP() {}
 int object::GetPS() {}
 
 double this->factor;
 int this->GetP() {}
 int object::GetPS()
 {
 double aa = (double)this->GetP() * this->factor;
 int bb = (int) aa;
 return bb;
 }
 
 Here the Assembly code generated in linux in optimize mode (O3):
 ===================
 .LFE223:
 .Lfe223:
         .size   _ZN17object9GetPSEv,.Lfe223-_ZN17object9GetPSEv
         .align 2
         .p2align 4,,15
 .globl _ZN17object13GetPSEv
         .type   _ZN17object13GetPSEv,@function
 _ZN17object13GetPSEv:
 .LFB224:
         pushl   %ebp
 .LCFI739:
         movl    %esp, %ebp
 .LCFI740:
         subl    $24, %esp
 .LCFI741:
         movl    %ebx, -4(%ebp)
 .LCFI742:
         movl    8(%ebp), %ebx
         movl    (%ebx), %eax
         movl    %ebx, (%esp)
         call    *220(%eax)
         pushl   %eax
         fildl   (%esp)
         addl    $4, %esp
         fmull   116(%ebx)
         fnstcw  -6(%ebp)
         movl    -4(%ebp), %ebx
         movzwl  -6(%ebp), %eax
         orw     $3072, %ax
         movw    %ax, -8(%ebp)
         fldcw   -8(%ebp)
         fistpl  -12(%ebp)
         fldcw   -6(%ebp)
         movl    -12(%ebp), %eax
         movl    %ebp, %esp
         popl    %ebp
         ret
 .LFE224:
 .Lfe224:
         .size   _ZN17object13GetPSEv,.Lfe224-_ZN1object13GetPSEv7
         .align 2
         .p2align 4,,15
 
 ===================
 Here the Assembly code generated in linux in optimize mode (O3):
 
 .LFE183:
 .Lfe183:
         .size   _ZN17object9GetPSEv,.Lfe183-_ZN17object9GetPSEv
         .align 2
 .globl _ZN17object13GetPSEv
         .type   _ZN17object13GetPSEv,@function
 _ZN17object13GetPSEv:
 .LFB184:
         .loc 1 5737 0
 .LBB414:
         pushl   %ebp
 .LCFI554:
         movl    %esp, %ebp
 .LCFI555:
         subl    $24, %esp
 .LCFI556:
         .loc 1 5739 0
         movl    8(%ebp), %eax
         movl    (%eax), %edx
         addl    $220, %edx
         movl    8(%ebp), %eax
         movl    %eax, (%esp)
         movl    (%edx), %eax
         call    *%eax
         pushl   %eax
         fildl   (%esp)
         leal    4(%esp), %esp
         movl    8(%ebp), %eax
         fmull   116(%eax)
         fstpl   -8(%ebp)
         .loc 1 5740 0
         fldl    -8(%ebp)
         fnstcw  -14(%ebp)
         movzwl  -14(%ebp), %eax
         orw     $3072, %ax
         movw    %ax, -16(%ebp)
         fldcw   -16(%ebp)
         fistpl  -12(%ebp)
         fldcw   -14(%ebp)
         .loc 1 5741 0
         movl    -12(%ebp), %eax
 .LBE414:
         pushl   %ebp
 .LCFI554:
         movl    %esp, %ebp
         .loc 1 5742 0
         leave
         ret
 .LFE184:
 .Lfe184:
 
 
 
 i was able to create a test case that shows the same behavior:
 
 ----
 #include <stdio.h>
 #include <stdlib.h>
 
 
 double tt = 0.000000005975;
 
 double afunction()
 {
   return (5.975e-9);
 }
 
 
 long getS()
 {
   return 3332;
 }
 
 long getP()
 {
   return 6665;
 }
 
 double getPSFactor()
 {
   return ( (double) getS() / (double) getP());
 }
 
 
 int main(int argc, char* argv[])
 {
 
 double temp = 1e12*afunction();
 long var_1 = (long)temp;
 long var_2 = (long)(1e12*afunction()) ;
 long var_3 = (long)(1e12*5.975e-9) ;
 double temp1 = tt;
 long var_4 = (long)(1e12*temp1) ;
 long var_5 = (long) (1e12*tt+0.5) ;
 printf("var_1: %08d\n", var_1);
 printf("var_2: %08d\n", var_2);
 printf("var_3: %08d\n", var_3);
 printf("var_4: %08d\n", var_4);
 printf("var_5: %08d\n", var_5);
 
   return 0;
 }
 
 
 ---
 
 
 results using:
 linux: debug libs
 var_1: 00005975
 var_2: 00005974
 var_3: 00005975
 var_4: 00005974
 var_5: 00005975
 
 linux opt libs:
 var_1: 00005975
 var_2: 00005975
 var_3: 00005975
 var_4: 00005974
 var_5: 00005975
 
 sol/nt:
 var_1: 00005975
 var_2: 00005975
 var_3: 00005975
 var_4: 00005975
 var_5: 00005975
 
 _________________________________________________________________
 Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
 http://join.msn.com/?page=features/junkmail
 


             reply	other threads:[~2003-05-14 15:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-14 15:16 omar beo [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-05-14 20:56 Wolfgang Bangerth
2003-05-14 19:26 omar beo
2003-05-14 15:14 bangerth
2003-05-14 14:36 Christian Ehrhardt
2003-05-14 10:48 giovannibajo
2003-05-14  6:26 Dara Hazeghi
2003-05-13 18:26 omarbeo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030514151601.9341.qmail@sources.redhat.com \
    --to=omarbeo@hotmail.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).