Search

Wrong ARM code with /O2 optimizations by Mārtiņš Možeiko

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 770433
Opened: 11/7/2012 9:37:30 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Following C++ code fragment generates incorrect ARM machine code.

static unsigned long long Foo(unsigned long long a0)
{
    return (15849689698036411425ULL * a0 << 28) + 7806753552930010092LL;
}

static unsigned long long Bar(unsigned long long a0, unsigned long long a1)
{
    return 13321957801405570171ULL * a0 + 3349182078252791521LL * a1 + 4322231949668103995LL;
}

static void FooBar(unsigned long long a0, unsigned long long& a1)
{
    volatile unsigned long long temp1 = 8157439093432398537;
    unsigned long long temp2 = Foo(temp1);
    a1 = Bar(a0, temp2);
}

void bug1()
{
    volatile unsigned long long a0 = 8624364270469118943;
    unsigned long long a1;
    FooBar(a0, a1);
    printf("%I64u", a1);
}
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012

Steps to reproduce

Call bug1() function from WinRT C++ application in Release|ARM configuration.
Using debugger examine a1 value that is passed to printf function. You'll see that it will be incorrect.

Product Language

English

Operating System

Windows 8

Operating System Language

English

Actual results

a1 contains 3775407870420126156.

Expected results

a1 should contain 14496453360080325068 - easy to verify with calculator, or simply by running application in Debug|ARM configuration (without optimizations).
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/8/2012 at 5:41 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Microsoft Visual Studio Connect Support Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 11/7/2012 at 9:51 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)
Sign in to post a workaround.