[Bug target/47617] SSE rounding mode works -g, not -O3

cck0011 at yahoo dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 9 02:50:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47617

--- Comment #8 from cck0011 at yahoo dot com 2011-02-09 02:08:23 UTC ---
Hi folks,

  First, thanks for working on this.

  Second, I read the link and I _think_ I understand it. Let me paraphrase it
back to you and you can tell me if I've got the point:

  There is an optimizer that extracts common expressions and evaluates them
once instead of every time they occur. (What's the name of that so I can call
it by the right name?) In my code it finds the expression:

  dest = _mm_cvtps_pi16(source);

  Several times. Since it doesn't see source changing, this expression only
gets evaluated once. Now, the change to rounding mode that happens with
_MM_SET_ROUNDING_MODE(...) isn't detected as something that would change the
value of the _mm_cvtps_pi16(...) expression, so the optimization is not
removed. Recognizing that change to rounding mode and reacting to it is what's
at the heart of bug 34678, and that's why this is a duplicate.

  The work-arounds are:

1)insert 'asm("":"+X"(source));' before changing rounding mode to make the
compiler re-evaluate expressions that use source.

2) do _MM_SET_ROUNDING_MODE(...) before any divisions or integer conversions
that might get optimized out. The scope of the optimization is a function body
and any inlined code. So do _MM_SET_ROUNDING_MODE early within that scope. 

  Is my understanding correct? 

  A few more questions:

  Will this bug exist on non-X86 processors?

  What does the 'asm("":"+X"(source));' expression do ?

  Will this syntax work for non-X86 processors?

  To be correct, should I compile with -frounding-math ?


Thanks!



More information about the Gcc-bugs mailing list