public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17759] New: Failure to emit code when using inline asm and optimizing
@ 2004-09-30 21:05 tsuraan-gcc at xyons dot net
  2004-09-30 21:35 ` [Bug c++/17759] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: tsuraan-gcc at xyons dot net @ 2004-09-30 21:05 UTC (permalink / raw)
  To: gcc-bugs

Using the following code:

void matrix_mult(float* dst, const float* mat, const float* vec, int count) {
    asm (
            //put matrix into xmm4-7
            "movaps (%0), %%xmm4\n\t"
            "movaps 16(%0), %%xmm5\n\t"
            "movaps 32(%0), %%xmm6\n\t"
            "movaps 48(%0), %%xmm7\n\t"
            :
            : "r"(mat)
        );
    do {
        asm (
            "movaps (%0), %%xmm0\n\t"
            "addl $16, %1\n\t"
            "movaps %%xmm0, %%xmm1\n\t"
            "addl $16, %0\n\t"
            "movaps %%xmm0, %%xmm2\n\t"
            "movaps %%xmm0, %%xmm3\n\t"
            "shufps $0x00, %%xmm0, %%xmm0\n\t"
            "shufps $0x55, %%xmm1, %%xmm1\n\t"
            "shufps $0xAA, %%xmm2, %%xmm2\n\t"
            "shufps $0xFF, %%xmm3, %%xmm3\n\t"
            "mulps %%xmm4, %%xmm0\n\t"
            "mulps %%xmm5, %%xmm1\n\t"
            "mulps %%xmm6, %%xmm2\n\t"
            "mulps %%xmm7, %%xmm3\n\t"
            "addps %%xmm0, %%xmm1\n\t"
            "addps %%xmm3, %%xmm2\n\t"
            "addps %%xmm2, %%xmm1\n\t"
            "movaps %%xmm1, -16(%1)\n\t"
#if 1
            : "+q"(vec), "+q"(dst)
#else
            :: "r"(vec), "r"(dst)
#endif
        );
        count--;
    } while(count);
}

With the #if statement the way that I have it currently, the compiler omits the entire second asm block 
when compiling -O1 or higher.  If the #if statement is set the other way, the code works in the higher 
optimization levels, but with O0 it doesn't function properly, probably because the compiler is using 
registers that are being wiped by the assembly part.  I'm sure my constraints are wrong, but having the 
compiler fail to emit code entirely seems like a bug to me.

-- 
           Summary: Failure to emit code when using inline asm and
                    optimizing
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tsuraan-gcc at xyons dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/17759] Failure to emit code when using inline asm and optimizing
  2004-09-30 21:05 [Bug c++/17759] New: Failure to emit code when using inline asm and optimizing tsuraan-gcc at xyons dot net
@ 2004-09-30 21:35 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-30 21:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-30 21:35 -------
Invalid as you are lying to the compiler and saying the address are only accessed and not the memory 
locations, clober "memory" and it will work.
AKA asm ("":::"memory");

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-30 21:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-30 21:05 [Bug c++/17759] New: Failure to emit code when using inline asm and optimizing tsuraan-gcc at xyons dot net
2004-09-30 21:35 ` [Bug c++/17759] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).