Home Dashboard Directory Help
Search

Incorrect code generation when optimizing and using SSE2 by yuriks


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 647064
Opened: 2/24/2011 6:07:23 PM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

When compiling the attached program with /O1 (or, by uncommenting the marked line in the source, with /O2.) and /arch:SSE2 the compiler generates incorrect code which causes wrong results to be calculated.
Details
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:17 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by Microsoft on 3/1/2011 at 12:28 PM
Thank you for the bug report. We are aware of this issue and will fix this in the next major product release.
In the meantime, you may need to workaround the problem by disabling optimization for the affected function.

Mark Levine
Visual C++
Posted by Microsoft on 2/25/2011 at 1:49 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/24/2011 at 6:14 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)
Posted by yuriks on 2/24/2011 at 6:12 PM
Thought I may as well post the source of the test case here:

/////////////////////////////////////
#include <iostream>
#include <cmath>

struct data
{
    float val;
};

void func(const data& origin)
{
    data tmp = origin;
    tmp.val += 1.f;
    int upz = int(tmp.val);
    int z = int(origin.val);
    for (; z < upz; ++z) {
        float value1 = std::sin(z * 2.f);
        // This needs to be added on /O2: std::cout << value << '\n';
        std::cout << z << '\n';
    }
}

int main()
{
    data origin = {8.f};
    func(origin);
    return 0;
}
/////////////////////////////////////
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
main.cpp 2/24/2011 434 bytes