Thread View: borland.public.cppbuilder.upgrade
2 messages
2 total messages
Started by Bruce Larrabee
Mon, 13 Mar 2006 14:12
Code is failing in BDS2006 when optimized for fastest code (-O2)
Author: Bruce Larrabee
Date: Mon, 13 Mar 2006 14:12
Date: Mon, 13 Mar 2006 14:12
109 lines
5269 bytes
5269 bytes
Hello everyone,
I'm having trouble with this code failing when optimized.
(for fastest code (-O2)) It works great otherwise (-Od).
When I trace it in the IDE's debugger it seems that it
seems that the final 'else' isn't getting called??
This leads to many of the array 'sheight' not being filled
with some values with causes the failure when 'sheight' is
used.
Any help will be appreciated!
Thanks,
Bruce Larrbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(height[triangle] > 0.0)
{
sheight[triangle] = 1;
}
else if(height[triangle] < 0.0)
{
sheight[triangle] = -1;
}
else
{
sheight[triangle] = 0;
}
asm sub triangle, 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Not Optimized == Works
01: 004A0ED1 DD9DF8FEFFFF fstp qword ptr [ebp-$00000108]
02: contour_rectangle.cpp.584: if(height[triangle] > 0.0)
03: 004A0ED7 8B4DA4 mov ecx,[ebp-$5c]
04: 004A0EDA DD84CD5CFFFFFF fld qword ptr [ebp+ecx*8-$00a4]
05: 004A0EE1 D81DE0184A00 fcomp dword ptr [$004a18e0]
06: 004A0EE7 DFE0 fstsw ax
07: 004A0EE9 9E sahf
08: 004A0EEA 7610 jbe $004a0efc
08: contour_rectangle.cpp.586: sheight[triangle] = 1;
10: 004A0EEC 8B55A4 mov edx,[ebp-$5c]
11: 004A0EEF C7849548FFFFFF01 mov [ebp+edx*4-$00b8],$00000001
12: contour_rectangle.cpp.587: }
13: 004A0EFA EB31 jmp $004a0f2d
14: contour_rectangle.cpp.588: else if(height[triangle] < 0.0)
15: 004A0EFC 8B4DA4 mov ecx,[ebp-$5c]
16: 004A0EFF DD84CD5CFFFFFF fld qword ptr [ebp+ecx*8-$00a4]
17: 004A0F06 D81DE0184A00 fcomp dword ptr [$004a18e0]
18: 004A0F0C DFE0 fstsw ax
19: 004A0F0E 9E sahf
20: 004A0F0F 7310 jnb $004a0f21
21: contour_rectangle.cpp.590: sheight[triangle] = -1;
22: 004A0F11 8B55A4 mov edx,[ebp-$5c]
23: 004A0F14 C7849548FFFFFFFF mov [ebp+edx*4-$00b8],$ffffffff
24: contour_rectangle.cpp.591: }
25: 004A0F1F EB0C jmp $004a0f2d
26: contour_rectangle.cpp.594: sheight[triangle] = 0;
27: 004A0F21 8B4DA4 mov ecx,[ebp-$5c]
28: 004A0F24 33C0 xor eax,eax
29: 004A0F26 89848D48FFFFFF mov [ebp+ecx*4-$00b8],eax
30: contour_rectangle.cpp.597: asm sub triangle, 1;
31: 004A0F2D 836DA401 sub dword ptr [ebp-$5c],$01
32: 004A0F31 8B55A4 mov edx,[ebp-$5c]
33: 004A0F34 85D2 test edx,edx
Optimized == Does Not Work
01: 004A17FF DD9DDCFEFFFF fstp qword ptr [ebp-$00000124]
02: contour_rectangle.cpp.584: if(height[triangle] > 0.0)
03: 004A1805 8B8578FFFFFF mov eax,[ebp-$00000088]
04: 004A180B DD00 fld qword ptr [eax]
05: 004A180D D81D0C224A00 fcomp dword ptr [$004a220c]
06: 004A1813 DFE0 fstsw ax
07: 004A1815 9E sahf
08: 004A1816 760E jbe $004a1826
09: contour_rectangle.cpp.586: sheight[triangle] = 1;
10: 004A1818 8B9568FFFFFF mov edx,[ebp-$00000098]
11: 004A181E C70201000000 mov [edx],$00000001
12: contour_rectangle.cpp.587: }
13: 004A1824 EB2B jmp $004a1851
14: contour_rectangle.cpp.588: else if(height[triangle] < 0.0)
15: 004A1826 8B8D78FFFFFF mov ecx,[ebp-$00000088]
16: 004A182C DD01 fld qword ptr [ecx]
17: 004A182E D81D0C224A00 fcomp dword ptr [$004a220c]
18: 004A1834 DFE0 fstsw ax
19: 004A1836 9E sahf
20: 004A1837 730E jnb $004a1847
21: contour_rectangle.cpp.590: sheight[triangle] = -1;
22: 004A1839 8B9568FFFFFF mov edx,[ebp-$00000098]
23: 004A183F C702FFFFFFFF mov [edx],$ffffffff
24: contour_rectangle.cpp.591: }
25: 004A1845 EB0A jmp $004a1851
26: contour_rectangle.cpp.594: sheight[triangle] = 0;
27: 004A1847 8B8D68FFFFFF mov ecx,[ebp-$00000098]
28: 004A184D 33C0 xor eax,eax
29: 004A184F 8901 mov [ecx],eax
30: contour_rectangle.cpp.597: asm sub triangle, 1;
31: 004A1851 836DA401 sub dword ptr [ebp-$5c],$01
32: 004A1855 8B55A4 mov edx,[ebp-$5c]
33: 004A1858 85D2 test edx,edx
Re: Code is failing in BDS2006 when optimized for fastest code (-O2)
Author: Bruce Larrabee
Date: Mon, 13 Mar 2006 16:44
Date: Mon, 13 Mar 2006 16:44
24 lines
1789 bytes
1789 bytes
David Dean wrote: > In article <44157de9@newsgroups.borland.com>, > Bruce Larrabee <bruce_l@westbrookent.com> wrote: > > >> Any help will be appreciated! > > > This looks like a good candidate for QC, but I would recommend > putting in clear examples for each possible outcome, so that it can be > easily shown that the optimized code fails to hit the final else. > Hello Dean, Ok, two questions. We you say, 'putting in clear examples for each possible outcome', by this do you mean examples of data values? (being as I provided both code examples?). Second, do I need to do something to submit this to QC? Thanks Dan, Bruce Larrabee
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads