[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] gcc optimization problem



Joe,

The problem started when I switched to a new machine for compiling. I don't 
have ready access to the old machine so I don't know what version of gcc 
was on it, but most certainly it was older. The code is believed to be good,  
I've been using it for quite some time (over a year) with no observed bugs. 
However, the specific case of 0.0 is very unlikely to occur in my input data. 
Thanks, I'll check on that.

For now I've just turned optimizations off and everything works. I thought 
maybe someone might know enough about gcc's optimizations to suggest 
what I need to change to allow the  compiler to handle this function correctly. 
I suppose there's probaby a pragma I can use to tell the compile to not 
optimize this particular function.

> For what it's worth, -O2 compilation of your code worked for me, but 
> I used gcc version 2.95.3.  The disassembled object code (included 
> below) looks to do what it should.  I presume gcc-2.96.98 is 
> generating different code for you.
> 
> Incidentally, shouldn't your function handle the special case of 0.0 
> on input?  I believe it presently translates 0.0 to 1.5e-39 
> (= 2^-129).
> 
> --Joe
> 
> 
> readFaxFloat.o:     file format elf32-i386
> 
> Disassembly of section .text:
> 
> 00000000 <readVaxFloat>:
>    0:   55                      push   %ebp
>    1:   89 e5                   mov    %esp,%ebp
>    3:   83 ec 10                sub    $0x10,%esp
>    6:   56                      push   %esi
>    7:   53                      push   %ebx
>    8:   8b 5d 08                mov    0x8(%ebp),%ebx
>    b:   0f b7 0b                movzwl (%ebx),%ecx
>    e:   89 c8                   mov    %ecx,%eax
>   10:   25 80 7f 00 00          and    $0x7f80,%eax
>   15:   89 ca                   mov    %ecx,%edx
>   17:   66 c1 e8 03             shr    $0x3,%ax
>   1b:   05 e0 37 00 00          add    $0x37e0,%eax
>   20:   81 e2 00 80 ff ff       and    $0xffff8000,%edx
>   26:   09 c2                   or     %eax,%edx
>   28:   89 c8                   mov    %ecx,%eax
>   2a:   83 e0 7f                and    $0x7f,%eax
>   2d:   8d 75 f8                lea    0xfffffff8(%ebp),%esi
>   30:   66 c1 e8 03             shr    $0x3,%ax
>   34:   09 c2                   or     %eax,%edx
>   36:   66 89 56 06             mov    %dx,0x6(%esi)
>   3a:   0f b7 53 02             movzwl 0x2(%ebx),%edx
>   3e:   89 d0                   mov    %edx,%eax
>   40:   66 c1 e8 03             shr    $0x3,%ax
>   44:   c1 e1 0d                shl    $0xd,%ecx
>   47:   09 c1                   or     %eax,%ecx
>   49:   66 89 4e 04             mov    %cx,0x4(%esi)
>   4d:   0f b7 4b 04             movzwl 0x4(%ebx),%ecx
>   51:   89 c8                   mov    %ecx,%eax
>   53:   66 c1 e8 03             shr    $0x3,%ax
>   57:   c1 e2 0d                shl    $0xd,%edx
>   5a:   09 c2                   or     %eax,%edx
>   5c:   66 89 56 02             mov    %dx,0x2(%esi)
>   60:   0f b7 43 06             movzwl 0x6(%ebx),%eax
>   64:   c1 e1 0d                shl    $0xd,%ecx
>   67:   66 c1 e8 03             shr    $0x3,%ax
>   6b:   09 c1                   or     %eax,%ecx
>   6d:   66 89 4d f8             mov    %cx,0xfffffff8(%ebp)
>   71:   5b                      pop    %ebx
>   72:   dd 45 f8                fldl   0xfffffff8(%ebp)
>   75:   5e                      pop    %esi
>   76:   c9                      leave  
>   77:   c3                      ret    
> 


D. Alan Stewart
Layton Graphics, Inc.
155 Woolco Dr.
Marietta, GA 30062
Voice: 770/973-4312
Fax: 800/367-8192
FTP: ftp.layton-graphics.com
WWW: www.layton-graphics.com


"As far as the laws of mathematics refer to reality, they
are not certain; and as far as they are certain, they do
not refer to reality." - Albert Einstein

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.