Optimization for Maximum speed generates wrong code 
Author Message
 Optimization for Maximum speed generates wrong code

Hi!

I'm using the latest VS-Version 7.0.9466. With the optimization for Maximum
speed the compiler generates the wrong code for this code part:

( y0, hoehe are int, sBreite, faktor are double. All 4 variables are
declared in the definition of the class)

if(hoehe > sBreite * faktor)
{
  if(biegeGrafikZeigen)
    y0 -= (hoehe - sBreite * faktor) /2.0;
  else
    y0 += (hoehe - sBreite * faktor) /2.0;

Quote:
}

If the if-condition is true, the program goes to the else condition. When I
change the code like this, the program runs OK:

  if(biegeGrafikZeigen)
  {
    MessageBeep(MB_OK);
    y0 -= (hoehe - sBreite * faktor) /2.0;
  }

When I set the optimization to custom and favor for fast code, the program
runs also correct (wihout the beep-line).

Regrads
Uwe Janssen



Sun, 11 Jul 2004 01:53:34 GMT  
 Optimization for Maximum speed generates wrong code

Quote:
>I'm using the latest VS-Version 7.0.9466. With the optimization for Maximum
>speed the compiler generates the wrong code for this code part:

Uwe,

Can you create a stand-alone console application that someone can
easily use to duplicate the problem. If you can, you could post it
here and/or submit it as a bug report.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Sun, 11 Jul 2004 03:17:17 GMT  
 Optimization for Maximum speed generates wrong code
Uwe,

If you could provide a small executable test case that reproduces the
problem it would be helpful.

I attempted to reproduce the problem using the information from your post
and what I found is that the actual code generated and executed was correct,
but when stepping through the optimized code in the de{*filter*}, the de{*filter*}
displays the source line for the code in the *else* when it goes to convert
the result of the arithmetic back to an integer (via a call to _ftol2())
before storing to y0.

If you still feel that there is a code optimization bug here please try to
provide an executable test that we can use to reproduce the problem, or if
that is not feasible please pre-process your source file (by adding the -P
switch to the compile to produce a .i file) and send the .i file along to
me.

Thank you,

Mark Lacey

Microsoft Visual C++ Program Management
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Hi!

> I'm using the latest VS-Version 7.0.9466. With the optimization for
Maximum
> speed the compiler generates the wrong code for this code part:

> ( y0, hoehe are int, sBreite, faktor are double. All 4 variables are
> declared in the definition of the class)

> if(hoehe > sBreite * faktor)
> {
>   if(biegeGrafikZeigen)
>     y0 -= (hoehe - sBreite * faktor) /2.0;
>   else
>     y0 += (hoehe - sBreite * faktor) /2.0;
> }

> If the if-condition is true, the program goes to the else condition. When
I
> change the code like this, the program runs OK:

>   if(biegeGrafikZeigen)
>   {
>     MessageBeep(MB_OK);
>     y0 -= (hoehe - sBreite * faktor) /2.0;
>   }

> When I set the optimization to custom and favor for fast code, the program
> runs also correct (wihout the beep-line).

> Regrads
> Uwe Janssen



Mon, 12 Jul 2004 04:27:02 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC++ 5.0 Maximum Speed Optimization Problem

2. VC++ 5.0 Maximum Speed Optimization Problem

3. Code Optimization for max speed (newbie)

4. Speed of generated code

5. CString BadPtr - wrong code generated ???

6. Difference between code optimization and compiler optimization?

7. Optimization for speed question.

8. maximize speed optimization

9. ? Bug with VC++5.0 Maximize Speed Optimization?

10. VC5.0 speed optimization: 1 = 0

11. VC 4.2, POW function, and Max Speed Optimization

12. Painting and Speed Optimization CListView

 

 
Powered by phpBB® Forum Software