Wrong comparison instruction selected for loop preamble - by A. Kliger

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 644615 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/16/2011 11:43:54 AM
Access Restriction Public


When generating code for a for-loop preamble after an if-statement, the generated code sometimes avoids oututting a CMP instruction and just outputs a conditional jump instruction reusing the previous values of the flags register.

It does this in /O2 and /O1 when the if-statement and the for-loop end up comparing the same pairs of registers.

However sometimes it gets the condition code wrong.  In the attached example, a JGE instruction is selected instead of a JL.

Compiling with /Od produces the expected result.  Incorrect behavior is observed in generating x86 and x64 code.  Incorrect behavior also present in Visual Studio 2008 SP1.
Sign in to post a comment.
Posted by Microsoft on 5/9/2011 at 4:03 PM
Thank you for submitting the bug. Yes, you are correct; the issue fix was prepared for an upcoming release of the compiler.

Thank you again,
Natalia Glagoleva,
Posted by A. Kliger on 4/21/2011 at 10:46 AM
Thank you for taking the time to work on this issue.

I just want to confirm that Microsoft Visual Studio 2010 Version 10.0.40219.1 SP1Rel continues to generate incorrect code.

I assume "Resolved as Fixed" means that it is fixed in a not-yet-shipping version.

Thanks again,
A. Kliger
Posted by Microsoft on 2/17/2011 at 12:09 AM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Microsoft on 2/16/2011 at 12:00 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)