Search

compiler bug with __m128i by dj_alek

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 733810
Opened: 3/28/2012 12:17:23 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
Project compiled with Debug configuration works well.
The same compiled with Release configuration returns wrong result.
Details (expand)

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

Visual Studio 2010 SP1

Steps to reproduce

__m128i Sub128128( __m128i A, __m128i B )
{
        __m128i result = _mm_sub_epi64( A, B );

        __m128i AL = _mm_move_epi64( A );
        __m128i BL = _mm_move_epi64( B );

        __m128i INV = _mm_xor_si128( AL, BL );

        __m128i AGB = _mm_cmpgt_epi8( AL, BL );
        AGB = _mm_xor_si128( AGB, INV );

        __m128i BGA = _mm_cmpgt_epi8( BL, AL );
        BGA = _mm_xor_si128( BGA, INV );

        __m128i BORROW = _mm_setzero_si128();
        BORROW = _mm_insert_epi16( BORROW, _mm_movemask_epi8( BGA ) > _mm_movemask_epi8( AGB ), 4 );

        result = _mm_sub_epi64( result, BORROW );

        return result;
}

void Prn128( const unsigned char* p, const wchar_t* pszPrefix = L"" )
{
        wprintf_s( L"%s", pszPrefix );

        p += 15;
        for ( int i = 0; i < 16; ++i, --p )
                wprintf_s( L"%02X ", (int)*p );

        wprintf_s( L"(msb...lsb)\n" );
}

int _tmain(int argc, _TCHAR* argv[])
{
        __declspec( align(16) ) unsigned char aA[16] = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33 };
        __declspec( align(16) ) unsigned char aB[16] = { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 };
        __declspec( align(16) ) unsigned char aR[16];

        _mm_store_si128( reinterpret_cast< __m128i* >( aR ), Sub128128( _mm_load_si128( reinterpret_cast< const __m128i* >( aA ) ), _mm_load_si128( reinterpret_cast< const __m128i* >( aB ) ) ) );

        Prn128( aA, L"A = " );
        Prn128( aB, L"B = " );
        Prn128( aR, L"A-B = " );

        return 0;
}

Product Language

English

Operating System

Windows XP

Operating System Language

Russian

Actual results

0x33333333333333332222222222222222

Expected results

0x22222222222222222222222222222222
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 4/12/2012 at 10:58 AM
There are currently no plans to make a general fix for this issue avaiable for Visual Sudio 2010. If you feel a fix is necessary for you or your orgnaization you may request a Hotfix for this issue through Microsoft Support (http://support.microsoft.com/select/default.aspx?target=assistance).

ian Bearman
VC++ Code Generation and Optmization

Posted by dj_alek on 4/12/2012 at 7:18 AM
and what about vs2010 fix?
Posted by Microsoft on 3/28/2012 at 4:28 PM
Thanks for reporting this issue. This has been fixed and the fix has been made available via the Dev11 Beta release.

Please let me know if you have any additional questions or concerns.

ian Bearman
VC++ Code Generation and Optmization
Posted by MS-Moderator08 [Feedback Moderator] on 3/28/2012 at 2:37 AM
Thank you for submitting feedback on Visual Studio 11 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 MS-Moderator01 on 3/28/2012 at 12:56 AM
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.