Software Archive
Read-only legacy content
17061 Discussions

ICPC missing reading back a var after an asm statement

Martin_K_6
Beginner
798 Views

Hi, Apologies for using the MIC forum for general compiler issues again. The following source code produces erroneous compiled code under both icpc 13.1.1.163 Build 20130313 and icpc 14.0.0.080 Build 20130728: [cpp] #include #include union u_t { __m128 n; float f[4]; }; static void testee( float x, float y, float z, float w, u_t& b) { u_t a2; a2.n = _mm_add_ps((__m128) { x, y, z, w }, (__m128) { x, y, z, w }); asm volatile ("" : : "x" (a2.n) : ); // side-effect with a2 asm volatile ("" : "=m" (b) : : ); // touch b b.n = _mm_mul_ps(b.n, (__m128) { x, y, z, w }); // > x; std::cin >> y; std::cin >> z; std::cin >> w; u_t b; std::cin >> b.f[0]; std::cin >> b.f[1]; std::cin >> b.f[2]; std::cin >> b.f[3]; for (size_t i = 0; i < 16; ++i) { asm volatile ("" : "=m" (x) : : ); // touch x asm volatile ("" : "=m" (y) : : ); // touch y asm volatile ("" : "=m" (z) : : ); // touch z asm volatile ("" : "=m" (w) : : ); // touch w testee(x, y, z, w, b); } return 0; } [/cpp] Both source code and resulting .s file attached.

0 Kudos
6 Replies
Kevin_D_Intel
Employee
798 Views

Thank you for reporting this issue. I will investigate and post a reply soon.

0 Kudos
Kevin_D_Intel
Employee
798 Views

I believe I have reproduced this. It appears after optimization, which includes inlining the function, that the read-back of b may have been hoisted from the loop. I sent this to Development (under the internal tracking id below) for further analysis and will update the post as I learn more.

(Internal tracking id: DPD200248830)

(Resolution Update on 05/30/2014): This defect is fixed in the Intel® C++ Composer XE 2013 SP1 Update 3 release (Version 14.0.3.174 Build 20140422 - Linux)

0 Kudos
Martin_K_6
Beginner
798 Views

Thank you, Kevin!

0 Kudos
Kevin_D_Intel
Employee
798 Views

Development identified the root cause as the compiler not recognizing the aliasing between "b" and "b.n" and to work around this to change the asm modifier to "b.n" and the compiler then gets the idea. I confirmed the work around.

I will provide another update on the status of the fix as I learn it.

0 Kudos
Martin_K_6
Beginner
798 Views

Thank you once again, Kevin. I, too, confirm that the workaround gets the job done.

0 Kudos
Kevin_D_Intel
Employee
798 Views

This defect is fixed in the Intel® C++ Composer XE 2013 SP1 Update 3 Release (Version 14.0.3.174 Build 20140422 - Linux) now available from our Intel Registration Center.

0 Kudos
Reply