ICPC missing reading back a var after an asm statement

ICPC missing reading back a var after an asm statement

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:

 #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; } 
Both source code and resulting .s file attached.

AttachmentSize
Download bug.tgz2.17 KB
7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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

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)

Thank you, Kevin!

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.

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

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.

Leave a Comment

Please sign in to add a comment. Not a member? Join today